use strict; use warnings; open my $fh,'<', 'input1.txt' or die; while (<$fh>) {print if /b/}