Determining if reference $ref is a Hash

M

Michaelp

Hello!

How do I cleanly determine if $ref refers to a hash?

To be used like:
if (isHash ($ref)){
# traverse the hash
}

Thanks

Michael
 
J

johannes keßler

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello!

How do I cleanly determine if $ref refers to a hash?

To be used like:
if (isHash ($ref)){
# traverse the hash
}

Thanks

Michael

Hello,

I did not tested this, but this could help:

http://www.perlmonks.org/?node_id=32129


PS: the google search termn was: "perl check if hash"

regards,
johannes keßler
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAkp4AcsACgkQE++2Zdc7EtfQGgCfc6jx1LOBLL83cVwtzCETV+Cf
/50AnjQbaSMyQC+S4gAj/UqCvviW949m
=oMOb
-----END PGP SIGNATURE-----
 
G

Graham Drabble

Hello!

How do I cleanly determine if $ref refers to a hash?

To be used like:
if (isHash ($ref)){
# traverse the hash
}

perldoc -f ref

if (ref($ref) eq "HASH") {
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top