in reply to Printing Random Image in HTML

#!usr/local/bin/perl use strict; $|++; my ($c, $id, $image, $url, $type, @imgs, $img); open DAT, "ads.dat" or die "Error: cannot open data file!\n"; my @imgdata=<DAT>; close DAT; $id = int(rand(scalar @imgdata)); $c = @imgdata[$id]; { chop $c; ($id,$image,$url,$type)=split(/\|/,$c); } print "Location: $type\n\n";
if u use flat files always remove the newline at the end of each row of your dataset when reading those :-), but make sure that the last row has a newline too so far this works :-) regards