On Mon, Aug 14, 2000 at 12:15:51PM -0700, Peter Scott wrote: > At 03:11 PM 8/14/00 -0400, Ronald J Kimball wrote: > >On Mon, Aug 14, 2000 at 12:00:09PM -0700, Peter Scott wrote: > > > At 11:17 AM 8/14/00 -0700, I wrote: > > > > perl -ne'/(.)(??{join"",map chr ord($1)+$_,1..3})/&&print' > > > > > > perl -ne'/(.)(??{$a=$b=$1;$b++;++$a.++$b.++$b})/&&print' > > > >Why do you use $a and $b instead of just $a? > > I tried, believe me :-) None of the expressions I could think of would > work. It may be a bug that they don't work, or a bug that the one above > does :-) Oh, it's because post-increment puts a pointer to a value on the stack, rather than the value itself. When you post-increment the same variable several times in the same expression, they'll end up pointing to the same location, and so they result in the same value. But now I'm not sure why the two ++$b's above don't have that problem! Try this instead: perl -ne'/(.)(??{$a=$1;$a++;$a++.$a++.$a})/&&print' Note that this solution (like your original above) will also match words containing the sequences 'xyzaa', 'yzaaab', and 'zaaabac'. :) Ronald ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe