in reply to Re: Opening random files then reading random lines from file.
in thread Opening random files then reading random lines from file.

my $random_file = $names[rand(@names-1)];

That will always skip the last element of @names.    It should be:

my $random_file = $names[ rand @names ];

Replies are listed 'Best First'.
Re^3: Opening random files then reading random lines from file.
by Marshall (Canon) on Apr 27, 2012 at 06:42 UTC
    Correct.

    These pesky "off-by-one" errors (the most common error in programming) are indeed annoying! But yes, you are correct! Thanks!

    previous post updated with comment.