in reply to simple regexp question
Maybe I'm missing something really obvious, but if the - (dash) is optional, then mark it such in the regular expression...
my ($year, $num) = ($_ =~ /^(\d{4})-?(\d+)$/);
This way you will be guaranteed of getting both parts, regardless of whether a dash is present or not.
• another intruder with the mooring in the heart of the Perl
|
|---|