Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: how to print key and value of hash as it is

by hippo (Bishop)
on Jun 03, 2016 at 08:14 UTC ( [id://1164841]=note: print w/replies, xml ) Need Help??


in reply to how to print key and value of hash as it is

print $b = $a;

It isn't immediately obvious to me what you expect this statement to do. What it actually does is to extract the value from $a, store it in $b and then print it. What did you intend?

Other things you might be interested to know:

  • while takes a logical expression to evaluate and you have not given it one.
  • $a and $b are not good choices for variable names especially when using sort.
  • The ordering of keys within hashes is not a trivial thing.
  • You never need double brackets around one expression in Perl.

It might be better all round for you to provide your expected output because it's not at all clear to me what your code is intended to do.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2024-04-18 11:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found