Random - need some help

They have: 850 posts

Joined: Jul 1999

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]]

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/

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.