[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] string increment



"David L. Nicol" wrote:
> 
>     perl -le'$_=aaaa;do{print}while(s/([^z])(z*)\Z/++($a=$1).$2/e)'
> 
> Oh, you already found that one 

For the record, that was a different Rick.

> 
>     perl -le'$_=aaaa;1while print,s/[^z]+/++($x=$&)/e'

It'll be hard to beat that.  Nice shot!

> 
> I do not understand the point behind having $\d and $& and so forth
> treated
> like constants.  The memory is reserved for them somewhere, I want to be
> able
> to modify it.  I guess I can't because taint checking would be too big a
> performance hit, and writing to them is rarely called for and is easily
> worked around.  Or is it because they are pointers directly into the
> matched
> string, instead of copies?

I think so.

-- 
Rick Delaney
rick.delaney@home.com

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe