On Tue, 29 Aug 2000 08:51:29 -0400, Mark-Jason Dominus wrote:
>There are many operations that would be simpler if there was
>a magic array that contained ($1, $2, $3, ...). If anyone wants to
>write an RFC on this, I will help.
Heh. I once complained about the lack of such an array, in
comp.lang.perl.misc, *years* ago.
My practical problem was something like this, in a translation program.
$phrase is one of many patterns in a table, to look for English phrases,
%translate contains the French translations. interpolate() is a sub that
fills in the parameters -- the numbers in the string):
$_ = "It is 5 past 10."
$phrase = 'it is (\d+) past (\d+)';
s/^$phrase/interpolate($translate{$phrase}, $1, $2)/ie;
The problem is that with variable patterns, you *don't know* how many
paren groups there are.
The solution they came upo with, was @+ and @-. I still can't work with
those. An array of matches, (e.g. @&) would be a lot easier. It could
also be a lot slower; see the discussion on $& for this. (mystery: how
can filling in $& be a lot slower than filling in $1?)
--
Bart.
- Re: RFC 110 (v3) counting matches Tom Christiansen
- Re: RFC 110 (v3) counting matches Jarkko Hietaniemi
- Re: RFC 110 (v3) counting matches Jarkko Hietaniemi
- Re: RFC 110 (v3) counting matches Mark-Jason Dominus
- Re: RFC 110 (v3) counting matches Nathan Wiger
- Re: RFC 110 (v3) counting matches Mark-Jason Dominus
- Re: RFC 110 (v3) counting matches Damien Neil
- Re: RFC 110 (v3) counting matches Mark-Jason Dominus
- Re: RFC 110 (v3) counting matches Philip Newton
- Re: RFC 110 (v3) counting matches Mark-Jason Dominus
- Re: RFC 110 (v3) counting matche... Bart Lateur
- Re: RFC 110 (v3) counting ma... Mark-Jason Dominus
- $& and copying: rfc 158 ... Uri Guttman
- Re: $& and copying: rfc ... Mark-Jason Dominus
- Re: $& and copying: rfc ... Tom Christiansen
- Re: $& and copying: rfc ... Mark-Jason Dominus
- Re: $& and copying: rfc ... Mark-Jason Dominus
- Re: RFC 110 (v3) counting matches Joe McMahon
- Re: RFC 110 (v3) counting matche... Tom Christiansen
- Re: RFC 110 (v3) counting ma... Jonathan Scott Duff
- Re: RFC 110 (v3) counting ma... Tom Christiansen
