Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
How do I insert a line of text into an existing array?
#!/usr/bin/perl use strict; use warnings; my @data; my $line; my %hashTemp; open(FH, "error_log"); @data = <FH>; foreach $line (@data) { if ($line =~ /notice/) { if ($line =~ /rdy/) { $line =~ s/ /,/g; my @L1 = split(/|notice|[[]|,mpmstats:,|[\t]|rdy,|bsy,|rd, +|wr,|ka,|log,|dns,|cls,/, $line); %hashTemp = map { $_ => 1 } @L1; print @L1; } } }
I would like the following to go on the first line in the array:
day, month, date, time, year, rdy, bsy, rd, wr, ka, log, dns, cls
The output currently looks like this:
Wed,Jun,13,10:42:35,2012,769,31,0,22,6,0,0,3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Insert Element Into Array
by frozenwithjoy (Priest) on Jun 21, 2012 at 05:51 UTC | |
|
Re: Insert Element Into Array
by NetWallah (Canon) on Jun 21, 2012 at 05:47 UTC | |
by Anonymous Monk on Jun 21, 2012 at 15:30 UTC | |
by NetWallah (Canon) on Jun 21, 2012 at 22:13 UTC | |
|
Re: Insert Element Into Array
by roboticus (Chancellor) on Jun 21, 2012 at 11:05 UTC | |
|
Re: Insert Element Into Array
by cheekuperl (Monk) on Jun 21, 2012 at 05:42 UTC |