in reply to Calculating Mount Point Capacity

Presumably some chap has written a module that'll do what you need, but I don't know of one. If you can do system("df"), though, why not? (After all, Perl is good at parsing this kind of stuff.)

By "the two line junk," do you mean the header line or the line wrapping/splitting when the device name is too long?

Filesystem 1k-blocks Used Available Use% Mounted on /dev/sdb2 614208 522868 59612 90% / /dev/sdb3 614660 472372 110560 82% /usr /devfs/scsi/host0/bus0/target8/lun0/part6 711508 376520 298844 56% /build /devfs/scsi/host0/bus0/target8/lun0/part7 711508 574500 100864 86% /arc/1

My df (fileutils 4.1) takes a -P (a.k.a. POSIXLY_CORRECT) which forces each record to be on the same line. Uglier for humans; prettier for Perl. But in case yours doesn't:

# capacity($mountpoint) # # Returns the capacity (in 1024-byte units) of the # filesystem at $mountpoint. # sub capacity { my ($mp) = @_; my ($head, $line, $extra) = `df -kl $mp`; $line .= $extra if defined $extra; return (split ' ', $line)[1]; }

Before using this function, be sure to consider: security ($mp is passed to the shell), error handling, efficiency (you will have to spawn a subshell for every filesystem), and portability (not every OS has df).