In a while loop, $month keeps being set to things like jan or October. And I want these to become 01 and 10 respectively. Right now, I have 12 regular expressions—one for each month individually:
$month =~ s/jan.*/01/i; $month =~ s/feb.*/02/i; $month =~ s/mar.*/03/i; $month =~ s/apr.*/04/i; $month =~ s/may.*/05/i; $month =~ s/jun.*/06/i; $month =~ s/jul.*/07/i; $month =~ s/aug.*/08/i; $month =~ s/sep.*/09/i; $month =~ s/oct.*/10/i; $month =~ s/nov.*/11/i; $month =~ s/dec.*/12/i;
Is there a shorter or more efficient way to write this? Perhaps in one line?Just wonderin'.
In reply to Quick search-and-replace month names for numbers by kangaroobin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |