Ricardo SIGNES wrote:

* "Randal L. Schwartz" <merlyn@stonehenge.com> [2006-11-14T16:34:43]

"Rob" == Rob Dixon <[EMAIL PROTECTED]> writes:

This is indeed a documentation bug. perlop says, in full:

~ The "=>" operator is a synonym for the comma, but forces any word
~ (consisting entirely of word characters) to its left to be interpreted as
~ a string (as of 5.001). This includes words that might otherwise be
~ considered a constant or function call.

So we just need to add "but does not start with a digit" to that sentence.
That's true in folklore, but not in the docs yet.  Yeah, docbug.
I'm sure the author there intended the same definition as is used for
Perl identifiers (variable names, package names, etc).

(That is some wide quoting!)

That isn't quite true, either.  The dash can be the first character, which is
not true of identifiers.

  DB<1> x [ -x => 1 ]
  0  ARRAY(0x18010cc)
     0  '-x'
     1  1

Not quite. Perl isn't considering the hyphen as part of the 'word' here, it's
just allowing negation on strings of non-numeric content. -'x' is simply '-x' as
far as Perl is concerned! The same applies to the other unary operators in the
same context. Since 'x' is true, !x gives the empty string for false, and ~x
gives a character with a value of 255 - ord 'x'. All of these are valid Perl in
the absence of the => as long as the string is explicitly quoted.

my @x = ( -x => !x => ~x => 'x' );

 is equivalent to

@x = (-'x', !'x', ~'x', 'x' );

 or

@x = ('-x', '', "\x87", 'x' );

So at least Perl's consistent about what's an identifier and what's not, even in
this instance :)

Rob


--
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