Hi, folks!
Over time, I've needed to change a group of numbers from this:
751,752...1087,1088
to this:
00751,00752...01087,01088
...in other words, I've needed to change a numeric loop variable into something with a consistent number of digits. In the past, I've done this:
$_ = "00000$num";
( $num ) = /(\d{5}$)/;
I'm not really comfortable messing with the default variable all the time, though. Is there a way to do something like this?...
$num =~ m/\d{5}$/;
...though I know this specific example doesn't work. Is there a better way to go about this?
Over time, I've needed to change a group of numbers from this:
751,752...1087,1088
to this:
00751,00752...01087,01088
...in other words, I've needed to change a numeric loop variable into something with a consistent number of digits. In the past, I've done this:
$_ = "00000$num";
( $num ) = /(\d{5}$)/;
I'm not really comfortable messing with the default variable all the time, though. Is there a way to do something like this?...
$num =~ m/\d{5}$/;
...though I know this specific example doesn't work. Is there a better way to go about this?