Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: references - proper use of infix (arrow) and deprecated hash references

by Theodore (Friar)
on Jul 18, 2017 at 08:47 UTC ( #1195299=note: print w/replies, xml ) Need Help??


in reply to references - proper use of infix (arrow) and deprecated hash references

Hi. %hash is not a a hash reference, is a hash. Check the following:
# This is a hash: my %hash = ( 1 => 'one', 2 => 'two', ); # This is a hash ref: my $hashref = { 1 => 'one', 2 => 'two', }; # This is a hash ref of the hash above: my $hashref2 = \%hash; # Get a hash value: print "Hash: " . $hash{1} . "\n"; # Get a hashref value: print "Hash ref: " . $hashref->{1} . "\n";
Edited: Also just noted that the values of your hash are array references, so the print line should be:
print $_, "\t", $hash{$_}->[1], "\t", $hash{$_}->[2], "\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1195299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2023-04-01 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?