Michael Corgan wrote:

> What I'm trying to write is a script to randomly write to standard output
> questions in a file everytime I execute the script.  I seem to be getting
> these errors, though and I'm just not sure what I'm doing wrong.  I'm not
> sure what the errors are telling me.
> 

have you try:

#!/usr/bin/perl -w
use strict;

#--
#-- random.pl
#--
push(my @buffer,<>);

print $buffer[int(rand(@buffer))];

__END__

[panda@dzhuo]$ random.pl foo.txt
cat,084328
[panda@dzhuo]$

prints a random line from foo.txt. this is NOT the best approach (ie, if 
file is big, it will eat up a lot of memory). there are better methods and 
if you are interested, a lot of people here can give you guide line.

david


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to