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.