Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Appending a character to a field
August 29, 2007, 8:22 pm
rate this thread
- it_says_BALLS_on_your forehead
August 29, 2007, 8:39 pm
Re: Appending a character to a field
This ignores the fact that Perl will warn if a string has trailing
non-numeric characters. This warning can be suppressed for a block with
no warnings 'numeric';
You should always check the return value of open.
You should probably use lexical filehandles.
You should probably use 3-arg open, as its safer.
open(my $DFOUT, '-|', '/usr/bin/df', '-k')
or die "cannot run df: $!";
$_ is implicitly used by the match operators, so
next if /Filesystem/i;
To add the % back on, the simplest means is to push "$_%" onto your
array instead of $_. A better answer may be to use the Filesys::Df or
Filesys::DfPortable module, and get the information straight from
statvfs(2) without needing to invoke df(1).
- » FAQ 4.64 How can I get the unique keys from two hashes?
- — Previous thread in » PERL Discussions