my $file = 'path/to/log.dat'; my $out = 'path/to/outfile.txt'; open(READ_LOG,"<$file") or die $!; my @lines = ; close READ_LOG; chomp(@lines); 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;