use strict; use warnings; my $file; chomp ($file = ); open (MYFILE,"<$file") or die $!; while (>) { if(/ALARM:/) { print "$.: $_"; } } close MYFILE;