in reply to XML Bare Hash Reference.
I think you should just remove the % in
return map $_->{'value'}, @{%$hash}{@_}; ^
Starting with 5.10, Perl changed (fixed) the way this hash-slice construct is interpreted, which would explain why it did work before upgrading...
(As there's no test for xget in the package, presumably no one has come across the issue yet.)
#!/usr/local/bin/perl -w use strict; sub xget { my $hash = shift; return map $_->{'value'}, @{%$hash}{@_}; } my $hash = { foo => { value => "FOO" }, bar => { value => "BAR" }, }; print "$_\n" for xget($hash, qw(foo bar) );
$ ./1024343.pl Can't use string ("2/8") as a HASH ref while "strict refs" in use at . +/1024343.pl line 9.
Fixed:
#!/usr/local/bin/perl -w use strict; sub xget { my $hash = shift; return map $_->{'value'}, @$hash{@_}; } my $hash = { foo => { value => "FOO" }, bar => { value => "BAR" }, }; print "$_\n" for xget($hash, qw(foo bar) );
$ ./1024343.pl FOO BAR
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: XML Bare Hash Reference.
by huchister (Acolyte) on Mar 19, 2013 at 18:41 UTC |
In Section
Seekers of Perl Wisdom