in reply to Re: Why is this auto-quoted?
in thread Why is this auto-quoted?

One effect of these rules is that -bareword is equivalent to the string "-bareword"
Not really quit!. Check with B::Deparse, then you will discovery that -bareword is equalvalent to -'bareword' not '-bareword'

perl -MO=Deparse -e' use warnings; use strict; my %ha = ( -foo => "bar"); print %ha; '
gives
use warnings; use strict; my %ha = (-'foo', 'bar'); print %ha; -e syntax OK
Though with "-foo" there is no need of "=>".

Replies are listed 'Best First'.
Re^3: Why is this auto-quoted?
by Anonymous Monk on Jul 31, 2013 at 03:39 UTC

    Not really quit!

    You know what the difference between -'foo' and '-foo' is? nothing

      You know what the difference between -'foo' and '-foo' is? nothing
      Interesting to note that -'foo' and -'+foo' deparse to the same thing, -'foo'. This could be a gotcha if you needed the + sign.

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

        This could be a gotcha if you needed the + sign.

        Sure, but why use the - in that case?

        :) see Re: Why is this auto-quoted? (because) and perlglossary#identifier and nans, infs, and vomit

        $ perl -wle " print +foo" Unquoted string "foo" may clash with future reserved word at -e line 1 +. Name "main::foo" used only once: possible typo at -e line 1. print() on unopened filehandle foo at -e line 1. $ perl -wle " print -+foo" Unquoted string "foo" may clash with future reserved word at -e line 1 +. -foo $ perl -wle " print -'+foo'" -foo $ perl -wle " print -(-foo)" +foo