while (my $line = <$fh> ) { if (index($line,$pattern) != -1 ) { ... } }