Random - need some help
Can someone give me an example of picking a random line out of a file?
Thanks
----------
[red][Rob P][/red]
[[email protected]]--[[icq]16560402[/icq]]
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
Anonymous posted this at 00:29 — 11th October 1999.
They have: 5,633 posts
Joined: Jan 1970
Code:
#!/usr/bin/perl
$file = "filename.txt";
open (F, $file);
@lines = <F>;
close F;
$random = $lines[rand(@lines)];
print "Content-type: text/html\n\n";
print $random;
----------
Reviews of the best resources for webmasters in your e-mail every week!
Subscribe for [red]FREE[/red] by going to http://www.web-reviews.com/
Rob Pengelly posted this at 01:21 — 11th October 1999.
They have: 850 posts
Joined: Jul 1999
Thanks a ton !
----------
[red][Rob P][/red]
[[email protected]]--[[icq]16560402[/icq]]
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.