foreach (@columns) { if ($_ =~ /month(\d+)/) { $month . $1 = $whatever_value; } }