I have following script but its not working as expected. Any clue???
############################################# #!/usr/local/bin/perl # Use either -h or -k flag or leave it blank for default (-k) # -h for human-readable size output # -k for 1k-block output $flag = "-h"; @df = `df $flag`; print "Content-type: text/htmln\n"; print "<table border=2>\n"; print "<tr>\n"; print "<td><b>Filesystem</b></td>\n"; if ($flag eq "-h") { print "<td><b>Size</b></td>\n"; } else { print "<td><b>1k-blocks</b></td>\n"; } print "<td><b>Used</b></td>\n"; print "<td><b>Avail</b></td>\n"; print "<td><b>Capacity</b></td>\n"; print "<td><b>Mounted on</b></td>\n"; print "</tr>\n"; foreach $line (@df) { next if ($line =~ /Filesystem/); ($fsystem,$blocks,$used,$avail,$capacity,$mounted) = split(/s+ +/,$line); print "fsystem is $fsystem\n"; print "blocks is $blocks\n"; print "used is $used\n"; print "avail is $avail\n"; print "capacity is $capacity\n"; print "mounted is $mounted\n"; ($number,$sign) = split(/%/,$capacity); if ($number < 60) { print "<tr bgcolor=green>\n"; } elsif (($number >= 60) && ($number < 90)) { print "<tr bgcolor=yellow>\n"; } else { print "<tr bgcolor=red>\n"; } # print "<td>$fsystem</td>\n"; print "<td>$blocks</td>\n"; print "<td>$used</td>\n"; print "<td>$avail</td>\n"; print "<td>$capacity</td>\n"; print "<td>$mounted</td>\n"; print "</tr>\n"; } print "</table>\n";

In reply to Re: df output in tabular form using perl by rajeshatbuzz
in thread df output in tabular form using perl by rajeshatbuzz

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.