in reply to Use of the => operator

When we have a non quoted word before the operator => we only can guarantee that this word won't be interpreted as a sub even when this sub exists. This doesn't mean that a number will be turned into a string, so, this is also valid:
%h = ( 1.000 => 'foo' ) ; print "value: $h{1}\n" ;
What make this valid:
$h{2.000} = 'bar' ; print "value: $h{2}\n" ;
What have nothing to do with the operator =>.

Graciliano M. P.
"Creativity is the expression of the liberty".

Replies are listed 'Best First'.
Re^2: Use of the => operator
by roju (Friar) on Aug 10, 2004 at 15:16 UTC
    From perlop: The => digraph is mostly just a synonym for the comma operator. It's useful for documenting arguments that come in pairs. As of release 5.001, it also forces any word to the left of it to be interpreted as a string.

    I'd call 01 a word, especially since 01 =~ /^\w+$/ will match. But yup, since perl defines Perl, 01 isn't a word ;)

      Maybe perlop need some updates!

      Graciliano M. P.
      "Creativity is the expression of the liberty".