in reply to when reading a file how to print a line one above the current line??

You might want to look into the module Tie::File which comes with perl 5.8. Alternatively, use something like

open my $fh => $file or die "Failed to open $file: $!\n"; my $last = ""; while (<$fh>) { print "$last$_" if /ALARM:/; $last = $_; } close $fh;

Abigail