(while wrestling with the approximate matching package...)
What would you think of an array called &, that is, '@&' (maybe
@SUB_MATCHES after 'use English'?) Read-only, would contain after a
regexp match all the (submatches). Sort of a shadow implementation of
the $1, $2, $3, ... like this: $&[0] eq $1, $&[1] eq $2, $&[2] eq $3,
... Advantage over the $1, $2, $3, ...: when constructing regexps in
run-time one would not need to track the number of () submatch
constructs but use $#& instead. Exempli gratia: picking the 2nd,3rd,
and the last submatches to be, say, concatenated and translated into
lowercase would be:
lc("@&[1,2,$#&]")
Or finding out the length of all the "even" submatches:
length("@&[map{2*$_}1..($#&-1)/2]")
This is, by strange coincidence, exactly what I have to do when
inspecting for 'insertions' while matching approximately...
++jhi;
P.S. I know, Tom thinks that an array called & would be Offensive
Line Noise :-)
What would you think of an array called &, that is, '@&' (maybe
@SUB_MATCHES after 'use English'?) Read-only, would contain after a
regexp match all the (submatches). Sort of a shadow implementation of
the $1, $2, $3, ... like this: $&[0] eq $1, $&[1] eq $2, $&[2] eq $3,
... Advantage over the $1, $2, $3, ...: when constructing regexps in
run-time one would not need to track the number of () submatch
constructs but use $#& instead. Exempli gratia: picking the 2nd,3rd,
and the last submatches to be, say, concatenated and translated into
lowercase would be:
lc("@&[1,2,$#&]")
Or finding out the length of all the "even" submatches:
length("@&[map{2*$_}1..($#&-1)/2]")
This is, by strange coincidence, exactly what I have to do when
inspecting for 'insertions' while matching approximately...
++jhi;
P.S. I know, Tom thinks that an array called & would be Offensive
Line Noise :-)