in reply to Print line from file only once even if occurrence of pattern is more than once in the line
i wrote something similar a while back .
@line = <filehandle> #filehandle used for opening the file foreach my $line (@lines) { #note i am matching a line doing something like printin +g and then using next .. if($line =~/^ProcessName:/){ $mess = substr $keyword , 13; $unirec{$id} .="$date,$id,$mess\n"; next; } if($line =~/^Process Message :/ ){ $mess = substr $keyword , 18; $unirec{$id} .="$date,$id,$mess\n"; next; } }
|
|---|