while (<>){ if(/pattern_I _want/){ ($syn_id, $con_id) = /^(\d+)\t\d\t\(\d+)/; # now that I'm here, pull out pieces of the strings while (/(pattern_I_want/)g){ ++chars{$1}; push @line, $1; ...