Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi monks,

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'};

In reply to Getting values in Hash Reference? by gube

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (1)
As of 2021-06-15 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (66 votes). Check out past polls.

    Notices?