On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote:
Yep, I'm stumped on what appears to be simple.
Would anyone care to explain the following?
sflinux themes # echo 500 | perl -ple 's|(\d)|length(9 x $1)|eg;'
500
essentially, (\d) should match just the '5' in 500. that puts $1 == the
literal 5. so you take length(9 x 5) which is nine repeated 5 times, and
the length of that is 5. That replaces the 5 with a ... 5?
Is my logic correct on this?
thanks,
- sf
Nope, but almost right. The g on the end means it matches (\d) as
many times as it can and applies length(9 x $1) for each one (due to
the e). You can see the behavior by saying
echo 500 | perl -ple 's|(\d)|length(9 x ($1+1))|eg;'
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/