On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote:
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?
I think you've got it, except it doesn't stop with the 5. Unless I'm missing something, that substitution means the same thing as this simpler one: s#(\d)#$1#g Unless the value of $1 is useful, it's hard to see what good this does. It replaces each digit with itself. As side effects it affects all the match variables, and it stringifies its target. Did you find that piece of code somewhere? Do you know what its author was trying to do? --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/