tcf03 has asked for the wisdom of the Perl Monks concerning the following question:
This is the code I have so far[printer_queue1] [user1] 5 jobs - 10 pages total [user2] 2 jobs - 1 page total [printer_queue2] [userx] 100 jobs - 300 pages total
one issue im having is the following lineuse strict; use warnings; use diagnostics; use Data::Dumper; open PAGELOG, "page_log" or die "unable to open pagelog: $!\n"; my %unique=(); my (@array, @queues); my @LOGLINES=map { split /^(.*)$/, $_ } <PAGELOG>; # Get all unique queue names for (@LOGLINES) { next unless /^\w+.*/; my $queue=$1 if /^(\w+)\s.*/; push (@queues, $queue) unless $unique{$queue}++; } for my $line(@LOGLINES) { chomp ($line); next unless ( $line =~ m/^\w+.*/ ); for my $queue (@queues) { chomp ($queue); next unless ($queue =~ m/\w+/); if (grep $queue, $line) { s/$1//g if ($line =~ m/.*(\[.*\])\s.*/); s/$1/ /g if ($line =~ m/^\w.*(\s\s).*/); my ($printer, $user, $jid, $page, $copies, $billing, $host +) = split(/ /, $line); push ( @array,[$queue, $user, $jid]) unless $unique{$jid}+ ++; } } } print Dumper @array;
is producing this errors/$1/ /g if ($line =~ m/^\w.*(\s\s).*/);
Use of uninitialized value in substitution (s///) at C:\Documents and Settings\Ted\Desktop\perl\cups .pl line 36, <PAGELOG> line 192.although the value of @array printed to Dumper looks promising, Im having trouble getting to my final goal. here is a sample of the page_log.
R_NETADMIN_NB apache 8 [22/Apr/2005:11:19:55 -0400] 1 1 - localhost R_NETADMIN_NB apache 9 [22/Apr/2005:12:53:19 -0400] 1 1 - localhost R_SPARE root 15 [25/Apr/2005:13:12:58 -0400] 1 1 - localhost R_SPARE root 15 [25/Apr/2005:13:15:00 -0400] 1 1 - localhost R_NETADMIN_NB apache 13 [25/Apr/2005:14:47:15 -0400] 1 1 - localhost R_SPARE root 15 [25/Apr/2005:14:47:27 -0400] 1 1 - localhost RSPARE root 16 [25/Apr/2005:14:53:52 -0400] 1 1 - localhost RSPARE_NB root 17 [25/Apr/2005:14:57:41 -0400] 1 1 - localhost RSPARE root 16 [25/Apr/2005:14:58:07 -0400] 1 1 - localhost R_NETADMIN_NB root 18 [25/Apr/2005:14:59:08 -0400] 1 1 - localhost R_NETADMIN_NB root 19 [25/Apr/2005:15:00:37 -0400] 1 1 - localhost Y_NETADMIN root 20 [25/Apr/2005:15:13:16 -0400] 1 1 - localhost Y_NETADMIN root 20 [25/Apr/2005:15:13:18 -0400] 1 1 - localhost Y_NETADMIN_NB root 21 [25/Apr/2005:15:14:21 -0400] 1 1 - localhost
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: combining elements of arrays
by jdporter (Paladin) on May 12, 2005 at 04:02 UTC | |
by tcf03 (Deacon) on May 12, 2005 at 13:27 UTC | |
|
Re: combining elements of arrays
by jhourcle (Prior) on May 12, 2005 at 03:54 UTC | |
|
Re: combining elements of arrays
by graff (Chancellor) on May 12, 2005 at 04:07 UTC | |
|
Re: combining elements of arrays
by Errto (Vicar) on May 12, 2005 at 03:55 UTC |