in reply to Splitting output of a system command into an array
You seem to have the method correct: use backticks (see perlop) to capture the output of free into a scalar. Then split on whitespace to get the "words":
my $free = `free`; my @words = split /\s+/, $free; shift @words if $words[0] eq '';
shift removes an empty string from @words caused by $free starting with spaces.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting output of a system command into an array
by jwkrahn (Abbot) on Sep 29, 2007 at 20:50 UTC | |
|
Re^2: Splitting output of a system command into an array
by sKiBa (Initiate) on Sep 29, 2007 at 17:58 UTC | |
by FunkyMonk (Bishop) on Sep 29, 2007 at 18:23 UTC |