On Thu, 31 Mar 2005 12:16:21 -0800, John W. Krahn wrote: > > Using the same regular expression twice is redundant. > 1 while $str =~ s/(?<=\@)(.+?)_/$1./; >
Beautiful! But also a bit mind bending. I see code like this and I think - "too clever". It's not easy, I think, to understand at once what this code does. That is why I do not use tricks like this. But it is nice :-) > > And yet in your examples you use @ in double quoted strings four times without > escaping it (hint: m// and s/// interpolate like double quoted strings.) > Ah, but there is an important difference - in all the cases I wrote, the characters following the '@' sign could not be a legal variable name, so there was no need to escape the '@'. For example, the code you wrote above could be written without the "\" before the "@": 1 while $str =~ s/(?<=@)(.+?)_/$1./; Go ahead and try it - I promise you it works. I don't know where this is documented*, so I can't prove this, but at least as far as the code, it works. So do my solutions, BTW - I tried them before posting. * If you or anyone else knows where this is documented, I'd love to know the location for future reference. Thanks. Cheers, -- Offer Kaye -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>