in reply to Re: Understanding arguments to subroutines
in thread Understanding arguments to subroutines

It seems like the doc is incomplete with regard to the dash character:
The => operator is a synonym for the comma except that it causes its left operand to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores. This includes operands that might otherwise be interpreted as operators, constants, single number v-strings or function calls. If in doubt about this behavior, the left operand can be quoted explicitly.

=> treats the dash as a string, although the doc does not mention it:

use warnings; use strict; use Data::Dumper; my %h = (-v => 5); print Dumper(\%h); print "$h{-v}\n"; __END__ $VAR1 = { '-v' => 5 }; 5

Replies are listed 'Best First'.
Re^3: Understanding arguments to subroutines
by Corion (Patriarch) on May 14, 2012 at 14:42 UTC

    I think you can explain it without a change to the documentaiton, and B::Deparse supports that:

    > perl -MO=Deparse -e "print for -verbose => 2" print $_ foreach (-'verbose', 2); -e syntax OK

    ... and the unary minus, when applied to a string, returns "-", prepended to that string, as documented in perlop for Symbolic Unary Operators.

      Agreed. Thanks for the link to the "-" doc.