open(FH, "error_log"); @data = for (my $index = 0; $index < $data; $index++) { my $line = @data[$index]; my $nextline = @data[$index + 1] if ($index < $data - 1); if ( ($line =~ /notice/)) { #format line $line =~ s/ /,/g; my @L1 = split(/|notice|\[|\]|,mpmstats:,|\t|rdy,|bsy,|rd,|wr,|ka,|log,|dns,|cls,|bsy:,|in,|/, $line); $line =~ s/|notice|\[|\]|,mpmstats:,|\t|rdy,|bsy,|rd,|wr,|ka,|log,|dns,|cls,|bsy:,|in,//g; print $line; #format nextline $nextline =~ s/ /,/g; my @L1 = split(/|notice|\[|\]|,mpmstats:,|\t|rdy,|bsy,|rd,|wr,|ka,|log,|dns,|cls,|bsy:,|in,|/, $nextline); $nextline =~ s/|notice|\[|\]|,mpmstats:,|\t|rdy,|bsy,|rd,|wr,|ka,|log,|dns,|cls,|bsy:,|in,//g; print $nextline; }