>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

Reply via email to