my %file = ( meminfo => '/proc/meminfo' ); my %mem; open MEM,'<',$file{meminfo} or die "Statistics: can't open $file{meminfo}"; while () { $mem{$1} = $2 if /^(MemTotal|MemFree|Buffers|Cached|SwapTotal|SwapFree):\s*(\d+)/ } close MEM;