Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

random image

by yuri (Initiate)
on Jun 06, 2001 at 10:36 UTC ( [id://86140]=obfuscated: print w/replies, xml ) Need Help??

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); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://86140]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-07-18 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.