Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    5

    Unanswered: check for hash ref in multi-dimensional hash

    hello:

    Can anyone tell me how to check to see if a hash key value is a reference to an anonymous hash?
    I've tried:
    if (keys %{ $hash{$key} } ) but this doesn't work when using the strict pragma.

    Thanks,

    Adam

  2. #2
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    Code:
    if(ref($hash{$key}) eq 'HASH'){
      print "Value is a reference on an anonymous hash\n";
    }
    else{
      print "Not a reference\n";
    }
    Last edited by reneeb; 05-12-04 at 07:09.
    board.perl-community.de - The German Perl-Community

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •