I'm a bit new to perl and had to write a small script to spit out a random image. Here's my obfu attempt:
#!/usr/bin/perl @files=('img1.jpg','img2.jpg','img3.jpg'); print "Content-type: image/" .(((split(/\./,$file=$files[ (rand(4700)%(scalar(@files)) )]))[1]=='jpg')?'jpeg':'gif' ) . "\n\n" ; if ( open (FID, $file)){ while(<FID>){ print $_; } close(FID); }

Replies are listed 'Best First'.
Re: random image
by iamcal (Friar) on Jun 06, 2001 at 11:36 UTC
    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); }