On Fri, 11 May 2007 18:24:14 -0400
Steve Finkelstein <[EMAIL PROTECTED]> wrote:

> Oh, so it goes through each and every character in the original string
> passed. I thought it takes in the string as one entity and just captures
> the first digit it can.
> 
> Does -p make it iterate over each character?
> 
> Martin Barth wrote:
> > On Fri, 11 May 2007 17:50:41 -0400
> > Steve Finkelstein <[EMAIL PROTECTED]> wrote:
> > 
> >> echo 500 | perl -ple 's|(\d)|length(9 x $1)|eg;'
> > 
> > no you're wrong:
> > s///g <- matches 5 first. length(9x5) == 5, thats true
> > 
> > but now next digit! 0 -> length ( 9 x 0 )  == length("") == 0
> > same again....
> > 
> > 
> 

sorry for didn't say it clear enough in my first mail, the thing you
made wrong is s///_g_ which iterates as long it dosnt match anymore.

try s///e without g. 

-p does 'while(<>){ ...code...  }' # which iterates over each line of
STDIN.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to