# wrong while (my $line = $fh){ # right while (my $line = <$fh >){ #### open (my $fh, "<", "test.txt"); my @file_array = (<$fh>); print @file_array,"\n"; #### #!/usr/bin/perl use warnings; use strict; # use ARGV's magic @ARGV = "test.txt"; my @results; while ( ){ chomp $_; if ($_ =~ m/head/){ push (@results, $_); } } print "@results\n";