Offer Kaye wrote:
On Thu, 31 Mar 2005 12:16:21 -0800, John W. Krahn wrote:

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,

$ perl -le' @) = qw/ a b c d /; print for @) ' a b c d $ perl -le' @/ = qw/ a b c d /; print for @/ ' a b c d $ perl -le' @" = qw/ a b c d /; print for @" ' a b c d


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.

perldoc perlop [snip] Quote and Quote-like Operators [snip] Interpolating an array or slice interpolates the elements in order, separated by the value of $", so is equivalent to interpolating "join $", @array". "Punctuation" arrays such as "@+" are only interpolated if the name is enclosed in braces "@{+}".



John
--
use Perl;
program
fulfillment

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




Reply via email to