#!/usr/bin/perl -w
 
@files = <[012]*.jpg>; #load files into array
 
$selected = $files[int(rand(1 * $#files+1)-1)]; # assign randomly selected file to var
 
$html = substr($selected, 0, -5).".html"; # create html filename
 
$fdate = substr($html, 0, -5); # extract date info from filename

$oldday=`date --date=$fdate "+%a, %d %B %Y"`;

#open(FH,$html) or die "an error occured: $!";
 
#while(<FH>)
#   {
#    if ($_ =~ /$selected/)
#       {
#         $grepstr = $_;
#       }
#   }
 
#close(FH);

@chunks = split /"/, $grepstr;

$width = $chunks[1]."\n";
$height = $chunks[3]."\n";
$caption = $chunks[7]."\n";

if ( $height gt $width )
   {
      $fheight = 335;
   }
   else
   {
      $fheight = 200;
   }

#print $oldday."<br />".$caption."<br /><img height='".$fheight."' src='".$selected."' alt='".$caption."' />\n";
print "<center><img height='".$fheight."' src='".$selected."' alt='".$caption."' /></center>\n";
