It would help if you said exactly what it is that you are trying to do. But I guess that you are trying to split a date into its components using a regular expression.
Well, you can capture (and assign) multiple parts of your expression in one go. So something like this:
my ($year, $month, $day) = $maxdate =~ m/(\d+)-(\d+)-(\d+)/;
Of course, with your sample you could do the same thing using split, eg:
my ($year, $month, $day) = split /-/, $maxdate;
But if you want something more robust and reliable, that can deal with different date formats - then you should look at one of the Date parsing modules available on CPAN.
Cheers,
Darren :) |