use strict; my $line; open FH, $ARGV[0] or die "Couldn't open input file" while ($line = ){ print $line if $line =~ /*I*like*foo*/; } close FH;