I am attempting to remove 3 commas from the file below but it is not working.
#!/usr/bin/perl
use strict;
use warnings;
my @data;
my @line;
open(FH, "error_log");
@data =
foreach $line (@data) {
if ($line =~ /notice/) {
if ($line =~ /rdy/) {
$line =~ s/ /,/g;
my @L1 = split(/notice|[[]|mpmstats:[\t]/, $line);
foreach $line (@L1) {
$line =~ s/,,,/,/g;
print @L1;
}
}
}
}
My output is as follows.
Wed,Jun,13,10:23:35,2012,,,rdy,769,busy,31,rd,0,wr,22,ka,6
Wed,Jun,13,10:42:57,2010,,,rdy,758,busy,41,rd,0,wr,54,ka,5
Why is the s/,,,/,/g; not substituting the single comma?