On Mon, 28 Aug 2000, Mark-Jason Dominus wrote:
> But there is no convenient way to run the loop once for each date and
> split the dates into pieces:
>
> # WRONG
> while (($mo, $dy, $yr) = ($string =~ /\d\d-\d\d-\d\d/g)) {
> ...
> }
What I use in a script of mine is:
while ($string =~ /(\d\d)-(\d\d)-(\d\d)/g) {
($mo, $dy, $yr) = ($1, $2, $3);
}
Although this, of course, also requires that you know the number of
backreferences. Nicer would be to be able to assign from @matchdata or
something like that :)
Cheers,
Philip
--
Philip Newton <newton@newton.digitalspace.net>
Thread Previous
|
Thread Next