my ($tot, $gcount, $ccount, $ocount); while (<>) { $tot=$1 if /^Total count\s+(\d+)/; $gcount = $1 if /^G\s+(\d+)/; $ccount = $1 if /^C\s+(\d+)/; $ocount = $1 if /^Other\s(\d+)/; }