>much possible action at a distance. I'm not seeing a nicely-parseable,
>easily-understandable way of doing this. Would this be a possible:
> $string =~ /(\d\d)-(\d\d)-(\d\d)?&{push @list,makedate(\1,\2,\3)}/g;
>Or is that just too ugly and nasty for words?
Yes, passing a reference to the numbers 1, 2, and 3 is clearly too ugly.
But you'll find we've already got that, I think.
sub makedate {
my($dd,$mm,$yy) = @_;
warn "Just got a date for @_\n";
return "[$yy/$mm/$dd]";
}
$string = "22-33-44 and 55-66-77 are ok";
@dates = ();
() = $string =~ m{
(\d\d) - (\d\d) - (\d\d)
(?{ push @dates, makedate($1,$2,$3) })
}gx;
print "Now the dates are: @dates\n";
Running that yields:
Just got a date for 22 33 44
Just got a date for 55 66 77
Now the dates are: [44/33/22] [77/66/55]
--tom
- Re: RFC 110 (v3) counting matches Philip Newton
- Re: RFC 110 (v3) counting matches Mark-Jason Dominus
- Re: RFC 110 (v3) counting matches Bart Lateur
- Re: RFC 110 (v3) counting matches Mark-Jason Dominus
- $& and copying: rfc 158 (was Re: RFC ... Uri Guttman
- Re: $& and copying: rfc 158 (was Re: ... Mark-Jason Dominus
- Re: $& and copying: rfc 158 (was Re: ... Tom Christiansen
- Re: $& and copying: rfc 158 (was Re: ... Mark-Jason Dominus
- Re: $& and copying: rfc 158 (was Re: ... Mark-Jason Dominus
- Re: RFC 110 (v3) counting matches Joe McMahon
- Re: RFC 110 (v3) counting matches Tom Christiansen
- Re: RFC 110 (v3) counting matches Jonathan Scott Duff
- Re: RFC 110 (v3) counting matches Tom Christiansen
- Re: RFC 110 (v3) counting matches Nathan Wiger
- Re: RFC 110 (v3) counting matches Jonathan Scott Duff
- Re: RFC 110 (v3) counting matches Nathan Wiger
- Re: RFC 110 (v3) counting matches Tom Christiansen
- Re: RFC 110 (v3) counting matches Nathan Wiger
- Re: RFC 110 (v3) counting matches Bart Lateur
- Re: RFC 110 (v3) counting matches Tom Christiansen
- Re: RFC 110 (v3) counting matches Bart Lateur
