open (IN, 'text.txt'); while (){ if ($_ =~ /^(\d)\s(\d)/){ $size = $1; $minmatch = $2; } else{ push(@array, $_); } }