SWM - non-smoker, desperately seeks...........Oops! wrong text.

I've got a problem consolidating information that is picked up from a while loop. Let's take a look........

my $count3 = 0; my $cgi3 = "$urchinpath/bin/urchin.cgi"; $ENV{REQUEST_METHOD} = "GET"; if (defined $field{$report3}) { $ENV{QUERY_STRING} = "r=$report3&b=$begin&e=$end&v=$max&rid=$rid&la +ng=$language&f=$field{$report3}"; } else { $ENV{QUERY_STRING} = "r=$report3&b=$begin&e=$end&v=$max&rid=$rid&la +ng=$language&f=$tab"; } open (CGI, "$cgi3 |") or die "Failed to open urchin.cgi: $!"; while(<CGI>) { if ($_ =~ /^parent.dLoad\((.*)\);?\s*/) { @line = split(/,/, $1); if (($report3 != 1102) && ($report3 != 1901) && ($report3 != 190 +2) && ($report3 != 1905)) { $line[0] = (split(/"/, $line[0]))[1]; } if (!defined $line[0]) { $line[0] = ""; } $line[1] = &formatNumber($line[1]); if (($report3 == 1101)) { printf("%-66s %13s\n", $line[0], $line[1]); #Here's the bugger. This is the line that prints what I need +. } elsif (defined $field{$report3}) { printf("%-66s %13s\n", $line[0], $line[($field{$report3}+1)]) +; } $count3++; } } close(CGI) or die "Failed to close urchin.cgi: $!"; exit;

This produces results that look like this:

Wed 1/01     1,342
Thu 1/02     1,876
Fri 1/03     2,467
Sat 1/04     1,567
Sun 1/05     3,899
Mon 1/06     2,544
Tue 1/07     1,235
Wed 1/08     2,099

What I need to do is format it like this:
Mon 2,544
Tue 1,235
Wed 3,441

Where I only list the day of the week once, but the numbers for this day is totaled. I'm trying to put this into a DB and it'd be a lot easier to put it in by day of month as opposed to by the day and have to create all these extra rows.

Too burnt to figure this out and need help! Anyone have any ideas?

peppiv


In reply to Consolidate info in a while() loop by peppiv

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.