in reply to Re: Understanding arguments to subroutines
in thread Understanding arguments to subroutines
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 | |
by toolic (Bishop) on May 14, 2012 at 14:52 UTC |