my $file = 'path/to/log.dat'; my $out = 'path/to/outfile.txt'; my @lines = (); open(READ_LOG,"<$file") or die $!; while(my $line = ){  chomp($line);  push(@lines,$line) if($line !~ /^\s*?$/); } close READ_LOG; my @entries = (); for(0..$#lines){ next unless($lines[$_] =~ /\[\d{2}\/\d{2}\/\d{4}/); push(@entries,$lines[$_].'; '.$lines[$_+1].'; '.$lines[$_+2]); } open(WRITE_OUT,">$out") or die $!; for(@entries){ print WRITE_OUT $_,"\n" if(index($_,'is Changed') != -1); } close WRITE_OUT;