Offer Kaye wrote:
On Thu, 31 Mar 2005 13:43:14 -0800, John W. Krahn wrote:

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 @) '

Educational thread, this :-)

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 "@{+}".

Ah, *now* I see why both my code and yours work - in my case, the
"variables" were not interpolated according to the rule you just
quoted. In your code:
$ perl -le' @) = qw/ a b c d /; print for @) '
There is no interpolation going on, so '@)' is treated as a variable name. Quick reality check for myself:
$ perl -le' @a = qw/ a b c d /; print for "@a"'
a b c d
$ perl -le' @) = qw/ a b c d /; print for "@)"'
@)


Now all is well :-)
But now I'm confused - if you knew of the above rule, why take me to
task for not escaping the '@' sign in my code?

Because I can. :-) No really, some versions of Perl will report that as an error.


perldoc perl56delta
[snip]
       In string, @%s now must be written as [EMAIL PROTECTED]
           The description of this error used to say:

                   (Someday it will simply assume that an unbackslashed @
                    interpolates an array.)

           That day has come, and this fatal error has been removed.  It has
           been replaced by a non-fatal warning instead.  See "Arrays now
           always interpolate into double-quoted strings" for details.



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