#!/usr/bin/perl use CGI qw(:standard); $filename = param("name"); open(PICLIST, "picturelist.xml") || ERRHANDLER(2); while() { $holdit = $_; if (getTag($holdit, "filename") eq $filename) { $fileday = getTag($_, "day"); $filemonth = getTag($_, "month"); $fileyear = getTag($_, "year"); $filetime = getTag($_, "time"); $filecapt = getTag($_, "caption"); $filecomm = getTag($_, "comments"); goto DONE; } } DONE: print "Content-Type: text/html; charset=UTF-8\n\n"; print "$filecapt
"; print ""; #for debugging #print "

$holdit

"; #print <File Name$filename #File Type$filetype #File Number$filenum #File Date$filedate #File time$filetime # #END_OF_TEXT #end debugging print "

$filecapt

$filemonth/$fileday/$fileyear

$filetime
Click here for full resolution
"; print "
"; sub ERRHANDLER { my($errnum) = @_; print h1("An error has occurred while running the cgi script."); if ($errnum == 1) { print h2("Unknown media file type"); } elsif ($errnum == 2) { print h2("Unable to open XML file"); } } ############################################################ sub getTag { my ($string, $element) = @_; my ($start, $end); if ($string =~ /<$element>/) { $start = index($string, "<$element>"); if ($start >= 0) { $start = (index($string, ">", $start) + 1); $end = index($string, "<", $start); if ($start >= 0) { return (substr($string, $start, $end-$start)) } } } return (""); }