my $test = '`dir $path /-c`'; my $free = &bleah( 'u:' ); print $free, "\n"; my $free = &bleah( 'c:' ); print $free, "\n"; sub bleah { my $path = shift; # # 1. evaluate the perl code in $test # when eval'ed, $path gets set internally # 2. get the last line of the result list # 3. match it against the given pattern # 4. the captured item gets returned in its own list # 5. return the captured item only (a scalar) # 6. voila - bytes free from DOS. # return ((eval $test)[-1] =~ m/(\d+) bytes free/)[0]; # yow! }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Real live code
by cored (Scribe) on Jul 14, 2003 at 14:11 UTC | |
|
Re: Real live code
by Anonymous Monk on Jul 11, 2003 at 19:59 UTC | |
|
Re: Real live code
by runrig (Abbot) on Jun 14, 2006 at 21:39 UTC | |
|
Re: Real live code
by Anonymous Monk on Jul 12, 2003 at 14:36 UTC | |
by Anonymous Monk on Jul 12, 2003 at 15:02 UTC | |
by rje (Deacon) on Jul 25, 2003 at 20:59 UTC |