Re: parsing report
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 24 Nov 2006 08:22:06 -0800
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%
**********************************************************************
.
- References:
- parsing report
- From: ccandillo
- parsing report
- Prev by Date: parsing report
- Next by Date: Re: parsing report
- Previous by thread: parsing report
- Next by thread: Re: parsing report
- Index(es):
Relevant Pages
|