more useful options | |
PerlMonks |
Re: Random entry from combined data setby damian1301 (Curate) |
on Jul 04, 2001 at 07:10 UTC ( [id://93759]=note: print w/replies, xml ) | Need Help?? |
Hmmm... what you could do is open each file and push (line by line) it in a single array.
Etc, etc. Then once you have all the files in a you can use a simple line to select a random phrase. note: This could drain some memory so be careful. Also, it would probably be much more efficient if you made a subroutine to open the files and return the data to you. That way you won't have so many open calls all the time. I will post an example in a bit. UPDATE:Got the sub.
UPDATE2: Use wog's advice, as his does not drain memory and has the same functionality as mine...but shorter. UPDATE3: I don't know why but I felt that push @bla,$_ while <FH>; was the best solution...man I am stoopid tonight... thanks dvergin.
In Section
Seekers of Perl Wisdom
|
|