[Israel.pm] (no subject)

Yuval Yaari yuval at windax.com
Sun Oct 22 08:58:40 PDT 2006


Levenglick Dov-RM07994 wrote:
> perl5.8.7 -e '$a="1.2.3.4.5.6.7.8.9.10";$a=~s/(\w+)\.(\w+)\.(\w+)\.(\w+)\.(\w+)\.(\w+)\.(\w+)\.(\w+)\.(\w+)\./\9/;print $a'
> Produces: 910
> 
> Why?
> 
> (It is also the case when running 5.6.1)

First of all, PLEASE use real subjects in your e-mails.
Thanks.

This is also the case when using bleadperl, not just 5.6.1 :)

Easy -- you match everything all the way to $9, which contains "9" and 
the last "." so generally you're replacing "1.2.3.4.5.6.7.8.9." (notice 
the trailing dot) with "9", and since you also have "10" after all the 
stuff you matched, you get "910".

Using the re pragma (perl -Mre=debugcolor), you can see your match:
18 <5.6.7.8.9.> <10>       | 73:                  END(0)

(Notice that <10> remains unmatched)

HTH,

   ~Y



More information about the Perl mailing list