c:\@Work\Perl>perl -wMstrict -le "for ('filesystem kbytes used avail capacity mounted on', '/dev/dsk/c0b0t0d0s4 12209400 5496486 6712914 46% /home', ) { printf qq{'%s' -> '%s' \n}, $_, parse_capacity($_); } ;; sub parse_capacity { my ($df_output) = @_; return $df_output =~ m[(\d+)%\s+/home$] ? $1 : 'Match Error'; } " 'filesystem kbytes used avail capacity mounted on' -> 'Match Error' '/dev/dsk/c0b0t0d0s4 12209400 5496486 6712914 46% /home' -> '46'