This is vitually straight out of the docs. Having read the ten lines of synopsis you have to call it like this which as you see performs as desired. The issue is that the df() method need to be called (it calls df(1) and caches the results) so that most of the other methods have data to work with. When reading those docs substitute Filesys::DiskFree->method() with $handle->method() and you should have no issues:

[root@devel3 root]# cat diskfree.pl #!/usr/bin/perl use Filesys::DiskFree; $handle = new Filesys::DiskFree; $handle->df(); my $device = $ARGV[0] || "/"; print "The $device device is ".$handle->device($device)."\n"; print "It has ".$handle->avail($device)." bytes available\n"; print "It has ".$handle->total($device)." bytes total\n"; print "It has ".$handle->used($device)." bytes used\n"; [root@devel3 root]# ./diskfree.pl The / device is /dev/sda3 It has 79425527808 bytes available It has 142137049088 bytes total It has 55491371008 bytes used [root@devel3 root]# ./diskfree.pl /boot The /boot device is /dev/sda1 It has 31190016 bytes available It has 47755264 bytes total It has 14099456 bytes used [root@devel3 root]# ./diskfree.pl /dev/sda1 The /dev/sda1 device is /dev/sda1 It has 31190016 bytes available It has 47755264 bytes total It has 14099456 bytes used [root@devel3 root]#

cheers

tachyon


In reply to Re: Re: Re: Problems using Filesys::DiskFree by tachyon
in thread Problems using Filesys::DiskFree by Ronnie

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.