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! }