Perl has an easy syntax for this, just use:
in reply to How to populate array with lines from text file? (Moved from Q&A)
Since <FH> is in array context ie. the left hand side of the assignment expects a list of items, it will fill the array with all the lines in the file.
open (FH, "< $file") or die "Can't open $file for read: $!";
my @lines = <FH>;
close FH or die "Cannot close $file: $!";
A few other points, your open shouldn't have angle brackets, @lines and $file should be declared with my() (I don't know why you aren't getting a compile time error from strict) and $line should be $_ (if you want to continue with the while loop).