Re: parsing report



In article <1164392103.945228.116470@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
ccandillo@xxxxxxxxx wrote:

DJ Stunks wrote:
ccandillo@xxxxxxxxx wrote:
I have a report that looks like the following. I am tring to add up
the disk space, total and used. Using regular expressions, I know how
to find the information that I am looking for but I do not know how to
add them up. Do I store them in hashes, arrays?

it depends how you want them grouped.

by server? (suggestion: hash of hashes)
by server and volume? (suggestion: hash of hashes of hashes)
not at all - ie: two totals? (suggestion: hash)
some other scheme? (suggestion: provide more information)

-jp

By server. If I can do that, then I would be able to create a final
total as well.

You can add the values to this kind of hash:

my %stats;

# in your loop that reads through the report and captures $server,
# $total, and $used

$stats{$server}->{total} += $total;
$stats{$server}->{used} += $used;

# at the end:

for my $server( sort keys %stats ){
print "For server $server\n";
print "\tTotal =\t$stats{$server}->{total} "
. "\tUsed =\t$stats{$server}->{used}\n";
}

Boyd
.



Relevant Pages

  • Re: parsing report
    ... Do I store them in hashes, ... (suggestion: hash of hashes of hashes) ... two totals? ...
    (perl.beginners)
  • Re: parsing report
    ... Do I store them in hashes, ... (suggestion: hash of hashes of hashes) ... two totals? ...
    (perl.beginners)
  • Re: Averages
    ... will see that your suggestion will not work AUTOMATICALLY if I add further ... other entries. ... the other totals of Cols. ... Use colons, not semi-colons! ...
    (microsoft.public.excel.newusers)
  • Re: aggregating time steps
    ... # store totals by month as: ... I didn't see %totals declared anywhere is the suggestion. ... Elements in the hash are accessed by ...
    (perl.beginners)
  • Re: Calculate Year To date Totals
    ... not give the YTD figures. ... Your suggestion seems to require ... > successive month totals to be included on the report in order to achieve ... > the totals for a single month, ...
    (microsoft.public.access.reports)