Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Building an arbitrary-depth, multi-level hash

by ikegami (Patriarch)
on Feb 28, 2009 at 22:11 UTC ( [id://747215]=note: print w/replies, xml ) Need Help??


in reply to Building an arbitrary-depth, multi-level hash

For starters, the syntax would be

# 'categories' entry is 'GNOME;Games;Action' push @{ $out{GNOME}{Games}{Action} }, $val; # 'GNOME;Games;Action;FPS' push @{ $out{GNOME}{Games}{Action}{FPS} }, $val; # ...and so on.

But you got another problem. You're trying to get an array reference and a hash reference to coexist in the same variable.

$out{GNOME}{Games}{Action}[0] = $val; $out{GNOME}{Games}{Action}{FPS}[0] = $val; ^ | XXX

Perhaps you could use the items of a specific category could be placed into a special* key. Say "_".

$out{GNOME}{Games}{Action}{_}[0] = $val; $out{GNOME}{Games}{Action}{FPS}{_}[0] = $val; ^ | Ok

* — Special to you, not to Perl.

Replies are listed 'Best First'.
Re^2: Building an arbitrary-depth, multi-level hash
by Anonymous Monk on Feb 28, 2009 at 22:54 UTC
    I see what you're saying - and thanks, I didn't think about trying to stuff both into the same variable! I still don't see how to resolve the original problem, however.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found