gube has asked for the wisdom of the Perl Monks concerning the following question:
I have a doubt in getting values in hash reference. Please see my by below code and comment and give me pour some idea about the code. I cannot understand this code, how it's working please some one give me an idea
"print @$hash_ref{'a', 'b'};"#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; #Hash my %hash = ('a' => 1, 'b' => 2); #To print the two values i have mentioned keys print @hash{'a', 'b'}; #Hash Reference my $hash_ref = \%hash; #To print the two values i have mentioned keys i am getting error (Glo +bal symbol "@hash_ref" requires explicit package name) print @hash_ref->{'a', 'b'}; #Prints values without error print @$hash_ref{'a', 'b'};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting values in Hash Reference?
by davorg (Chancellor) on Apr 24, 2006 at 11:13 UTC | |
|
Re: Getting values in Hash Reference?
by jonadab (Parson) on Apr 24, 2006 at 11:55 UTC | |
by Anonymous Monk on Apr 24, 2006 at 13:53 UTC | |
by jonadab (Parson) on Apr 25, 2006 at 11:30 UTC | |
by abuomarm (Initiate) on Sep 03, 2013 at 22:40 UTC | |
by Anonymous Monk on Sep 07, 2017 at 09:46 UTC |