my @lines; while ( my $line = <$input_fh> ) { push @lines, $line if $line =~ /WORD/; }