if ($file_in_question =~ /^(\d{4})/){ $year = $1; } #### print OUT for map{ s[(^\d+\s+)[\d\.]+\s+][$1]; "$year\t$_"; } sort { # ... etc.