http://www.perlmonks.org?node_id=86145


in reply to random image

A brief breakdown:
#!/usr/bin/perl @files=('img1.jpg','img2.jpg','img3.jpg'); $r = rand(4700)%(scalar(@files)); $file = $files[$r]; print "Content-type: image/"; print ((split(/\./,$file)[1]=='jpg')?'jpeg':'gif'); print "\n\n"; if (open(FID,$file)){ while($data = <FID>){ print $data; } close(FID); }