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.

In reply to Re: couple of file content manipulation questions by arthas
in thread couple of file content manipulation questions by vxp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.