in reply to couple of file content manipulation questions

Hi!

I took a few minutes to create the following code. Although a bit confused ( ;-) ), it parses all you need and prints in out some fomat I decided. Instead of printing, you can store the data in an hash or other structure you might like and do something later with that.

A couple of caveats:
Anyhow, I hope it can be useful as a hint for you.
use strict; open(LOG, '<', 'input.txt') or die $!; while(my $line = <LOG>) { chomp ($line); if ($line =~ /^(\w+\.snap\.synapticcorp\.com)\s+([\w\s\:]+)\s*$/) +{ print "Statistic for server $1, on $2\n"; } elsif ($line =~ /^([\/\w]+)\s+(\w+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\ +d+)\s+([\/\w]+)\s*$/) { print "Occupancy on $1 (fs $2, mounted on $7) is $4 out of $3 +($5 free, use $6%)\n"; } elsif ($line =~ /^TOTAL:\s+(\d+)\s+/) { print "Total: $1\n"; my $tmp = <LOG>; $tmp =~ /^USED:\s+(\d+)\s+([\d\.]+)%\s*$/; print "Used: $1 ($2%)\n"; $tmp = <LOG>; $tmp =~ /^AVAILABLE:\s+(\d+)\s+([\d\.]+)%\s*$/; print "Avail: $1 ($2%)\n"; print "\n\n"; } } close(LOG);


Michele.