in reply to Putting files in an Array

I am trying to put each line of a text file in an array
All you need is this (after opening the file):
@lines=<FILEHANDLE> #slurp it
But I see your code conditionally pushes elements into array. Nothing seems wrong with the code. Two things:
1) Open file statement is missing.
2) Instead of using $_ everywhere, use your own variable.

Replies are listed 'Best First'.
Re^2: Putting files in an Array
by monsoon (Pilgrim) on Jul 11, 2012 at 15:27 UTC
    It looks like there's no need to open the file here, because the filename is in the @ARGV. It is as if it comes from STDIN. In this case this works @lines=<>;