Chas Owens wrote: > On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote: >> On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote: >> > On 5/11/07, 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? >> > >> > No, the -ple causes it to write the code like this: >> > >> > $\ = $/; >> > LOOP: >> > WHILE (<>) { >> > s/|(\d)|length(9 x $1)|eg; >> > } >> > >> > The g on the end of the regex causes it to apply the pattern multiple >> > times. The e on the end of the regex makes it treat the replacement >> > like code instead of a string. >> >> Whoops, that should be >> >> $\ = $/; >> LOOP: >> WHILE (<>) { >> chomp; >> s/|(\d)|length(9 x $1)|eg; >> } > > Durn it, I will get it right eventually. > > $\ = $/; > LOOP: > WHILE (<>) { > chomp; > s/|(\d)|length(9 x $1)|eg; > print; > }
That should (correctly) be: $\ = $/; LOOP: while ( <> ) { # case matters - there is no WHILE chomp; s/|(\d)|length(9 x $1)|eg; } continue { print; } John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/