in reply to Regular Expression
if ($month =~ /^\d$/) { $month = '0' . $month; }
Note that there is no need to capture the match with parentheses. This is a bit overkill for simply formating a number, though. Why not just use sprintf?
$month = sprintf("%02d", $month);
Update: Corrected typo.
|
|---|