Re: parsing report



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?

Why would you need to store them at all? Nothing in your description
indicates you need anything but the sums...

Presuming your entire string is in $report...
my ($sum_total, $sum_used);
while (my ($total) = ($report =~ /Total volume space:\s+([\d,]+)/g) {
$total =~ tr/,//d;
$sum_total += $total;
}
while (my ($used) = ($report =~ /Space used:\s+([\d,]+)/g) {
$used =~ tr/,//d;
$sum_used += $used;
}
print "Total Disk space: $sum_total\n";
print "Total Used Disk space: $sum_used\n";

Paul Lalli

[leaving quoted data at bottom for reference sake...]



REPORT:

Statistics for fixed volume SERVER1/VOL1:

Total volume space: 10,172,164 100.00%
Space used: 7,865,744 77.33%

**********************************************************************

Statistics for fixed volume SERVER1/VOL2:

Total volume space: 167,167,132 100.00%
Space used: 105,169,536 62.91%


**********************************************************************

Statistics for fixed volume SERVER2/VOL1:

Total volume space: 6,076,752 100.00%
Space used: 3,639,684 59.90%

**********************************************************************

.



Relevant Pages

  • parsing report
    ... the disk space, total and used. ... Using regular expressions, I know how ... Statistics for fixed volume SERVER1/VOL1: ...
    (perl.beginners)
  • parsing report
    ... the disk space, total and used. ... Using regular expressions, I know how ... Statistics for fixed volume SERVER1/VOL1: ...
    (perl.beginners)
  • Re: Fastest way to store ints and floats on disk
    ... store it on disk, be able to read incrementally, and make statistics. ... I'm thinking about a binary format, ...
    (comp.lang.python)
  • [tip:sched/balancing] sched: Define structure to store the sched_group statistics for fbg()
    ... Commit-ID: 381be78fdc829a22f6327a0ed09f54b6270a976d ... Define structure to store the sched_group statistics for fbg ... Currently a whole bunch of variables are used to store the ... don't include that group in power savings calculations ...
    (Linux-Kernel)
  • Re: tar statistics
    ... I am using tar for my daily backups: ... I would like to collect statistics on how many new files were ... and store that in a log file. ...
    (comp.unix.shell)