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);
In reply to Re: couple of file content manipulation questions
by arthas
in thread couple of file content manipulation questions
by vxp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |