go ahead... be a heretic | |
PerlMonks |
Re: printing contents of a hashby Athanasius (Archbishop) |
on Apr 05, 2021 at 07:32 UTC ( [id://11130832]=note: print w/replies, xml ) | Need Help?? |
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:
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,
In Section
Seekers of Perl Wisdom
|
|