The code im posting has some issues - I know. My end goal is to have output something like this:
[printer_queue1] [user1] 5 jobs - 10 pages total [user2] 2 jobs - 1 page total [printer_queue2] [userx] 100 jobs - 300 pages total
This is the code I have so far
use 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;
one issue im having is the following line
s/$1/ /g if ($line =~ m/^\w.*(\s\s).*/);
is producing this error
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

Im not too sure what steps to take next.
Thanks in advance

UPDATE
Thanks! I worked longer than I needed to on this. Thanks for your suggestions! I learn new/better ways to do things here every day - my perl coding has improved vastly over the past few months from the suggestions and examples I have gotten here - I only hope I can offer someone this kind of help someday... I still have much to learn.

Ted
--
"Men have become the tools of their tools."
  --Henry David Thoreau

In reply to combining elements of arrays by tcf03

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.