use strict; use warnings; my $prtconfCmd = q{/usr/sbin/prtconf}; open my $prtconfFH, q{-|}, $prtconfCmd or die qq{fork: $prtconfCmd: $!\n}; my $memVal = q{}; while ( <$prtconfFH> ) { next unless m{^Mem.*?:\s+(\d+\s+\S+)}; $memVal = $1; last; } close $prtconfFH; print qq{Total memory is: $memVal\n};