Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: parsing file

by TexasTess (Beadle)
on Jul 08, 2002 at 23:23 UTC ( #180348=note: print w/replies, xml ) Need Help??


in reply to parsing file

You can do a while loop and load them into an array..then use the random number generator to randomly select a value from zero to max array index and thus select ONE of them...randomly...
open(FILE,$FILEVARNAME); While(<FILE>){ (/^\s*$/) and next; chomp $_; push(@array,$_); } close(<FILE>); $SIZE=@array; $select = rand($SIZE); print @array[$select];


TexasTess
"Great Spirits Often Encounter Violent Opposition From Mediocre Minds" --Albert Einstein

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2023-02-04 03:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (30 votes). Check out past polls.

    Notices?