in reply to A quick date swap from a string

Perhaps this is what you want:
foreach my $num (@tokens) { my $strBegin = uc substr($num, 0, 3); $date = $months{$strBegin} if exists $months{$strBegin}; }

I don't know what data you're processing, but this method doesn't look reliable.