I've cobbled some code together that will allow me to parse a file
snarfing 4 lines which consist of server name and Daily output of
bandwith usage. I've pasted an example of what I have at the bottom of
this mail. If anyone would like to take the time to show me how it
should really be done I would apreciate it. I'm not exactly a
programming wonder and trying to learn.
Thanks,
Kent
#!/usr/bin/perl
use warnings;
use strict;
my @lines;
while ( <DATA> ) {
push ( @lines, $_ );
}
for ( my $count = 0; $count <= $#lines; $count++ ) {
if ( $lines[$count] =~ m/\*/g ) { # grab server names
print "$lines[$count]";
}
if ( $lines[$count] =~ m/Daily/g ) { # grab daily output
print "$lines[$count] $lines[$count+1] $lines[$count+2]\n";
}
}
__DATA__
* Leo
# Bandwidth Usage
eth0 Total for 106.95 days:
RX 307.28 MB
TX 768.05 MB
eth0 Daily average:
RX 2.87 MB
TX 7.18 MB
* Buffy2
# Bandwidth Usage
eth0 Total for 14.70 days:
RX 141.28 MB
TX 2.03 MB
eth0 Daily average:
RX 9.61 MB
TX 0.14 MB
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>