[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Associative Arrays of Arrays?



Dennis Drescher writes on 19-JUL-1996:

>Hey.  I've got a general Perl-related question: I'm trying to create an
>associative array containing associative arrays; for example:
>
>   $hashref = { "section" , { "key"  , "value" },
>                "GLOBAL"  , { "key2" , "value2"} };
>
>This works fine (as a definition) -- however, I can't seem to get the 'keys'
>function to work on this!
>
>   keys($hashref)    [or any other variant I try...]

How about this?:

   keys(%$hashref)

>creates compiler errors complaining I'm trying to access a non-hash object.
>
>I can get data in, I just can't get it back out!
>
>Actually, this:
>   printf "section:key -> %s\n", $$hashref{"section"}{"key"} ;
>works fine. [  'keys $$hashref' doesn't work, either! ]
>
>I'm sure there's a simple way to do this.  Can anyone help me!?

If you didn't like the perlref.html page try this one:

   http://www.teleport.com/~merlyn/UnixReview/col07.html

Peter Prymmer
pvhp@lns62.lns.cornell.edu