if ($file_in_question =~ /^(\d{4})/){ $year = $1; } else { next; }