Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: printing contents of a hash

by Athanasius (Archbishop)
on Apr 05, 2021 at 07:32 UTC ( [id://11130832]=note: print w/replies, xml ) Need Help??


in reply to printing contents of a hash

Hello merrittr,

If you just want to print out a particular key/value pair, and you know the key, use something like print $key, ', ', $reg_coes{$key} (or $reg_coes->{$key} if $reg_coes is a hash reference). But I assume you want to print out the whole hash, in which case see the FAQ How do I process an entire hash? for various approaches.

An alternative is to use a module such as Data::Dumper or (my usual preference) Data::Dump. For the latter, you just do:

use Data::Dump; ... dd \%reg_coes;

and the module does the hard work for you.

Note that hashes are unsorted, so if you want to print out the contents in a particular order, you need to impose that order manually, as shown in the FAQ.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 17:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found