You sure the - stringifies? Try this: use strict;
use warnings;
use Data::Dumper;
my %a = (-keys => 'v1',
-values => 'v2');
print Dumper(\%a);
Gives (as expected):$VAR1 = {
'-keys' => 'v1',
'-values' => 'v2'
};
keys and values are (of course) builtins. When I replace the 'fat comma' with an ordinary one:my %a = (-keys , 'v1',
-values , 'v2');
I get:Not enough arguments for keys at C:\gash.pl line 6, near "keys ,"
Not enough arguments for values at C:\gash.pl line 7, near "values ,"
It was the fat comma doing the stringification, not the -.
Update: Re-reading the previous post, Anon did say "things that look like strings", which is correct. keys and values "look like" Perl builtins. Changing the names gives different results:my %a = (-xkeys , 'v1',
-xvalues , 'v2');
Gives:$VAR1 = {
'-xvalues' => 'v2',
'-xkeys' => 'v1'
};
Which I guess means it is not a good idea to rely on - to do stringification.
|