in reply to anyway to combine these two steps?
You are assuming it always matches (or else you'd get a warning), so I'm going to rely on that same assumption.
($num) = $num =~ /2(0\d)/;
Without the assumption:
$num = $num =~ /2(0\d)/ ? $1 : undef;
An alternate solution:
(...) = map sprintf('%02d', $_), ...
|
|---|