in reply to Stuck with Creating Multi-Level hash

Skimming over your post quickly, I noticed this:
$Menu_Multi_Hash{'L1A'}{'L2A'} = 'none'; .... $Menu_Multi_Hash{'L1A'}{'L2A'}{'L3B'}{'L4A'} = 'exe command';
That's not possible. $Menu_Multi_Hash{'L1A'}{'L2A'} can either be data, or the hashref pointing to the next level, but never both.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: Stuck with Creating Multi-Level hash
by sara2005 (Scribe) on May 27, 2006 at 00:34 UTC

    Below is the simple code that builds the multi-hash data structure..

    use Data::Dumper; use Tie::Autotie 'Tie::IxHash'; tie my %Menu_Multi_Hash, 'Tie::IxHash'; $Menu_Multi_Hash{'L1A'}{'L2A'} = undef; $Menu_Multi_Hash{'L1A'}{'Second'} = undef; $Menu_Multi_Hash{'L1A'}{'L2A'}{'L3A'} = undef; $Menu_Multi_Hash{'L1A'}{'L2A'}{'L3B'} = undef; $Menu_Multi_Hash{'L1A'}{'L2A'}{'L3A'}{'L4A'} = '/path/to/exe'; $Menu_Multi_Hash{'L1A'}{'L2A'}{'L3A'}{'L3B1'} = '/path/to/exe'; $Menu_Multi_Hash{'L1A'}{'L2A'}{'L3B'}{'L4A'} = '/path/to/exe'; $Menu_Multi_Hash{'L1A'}{'Second'}{'L3B'} = '/path/to/exe'; $Menu_Multi_Hash{'L1A'}{'Second'}{'Third1'} = '/path/to/exe'; print Dumper(\%Menu_Multi_Hash);

    The output is as follows:

    $VAR1 = { 'L1A' => { 'L2A' => { 'L3A' => { 'L4A' => '/path/to/exe', 'L3B1' => '/path/to/exe' }, 'L3B' => { 'L4A' => '/path/to/exe' } }, 'Second' => { 'L3B' => '/path/to/exe', 'Third1' => '/path/to/exe' } } };

    Hence, I was under the impression that if I can achieve this in an efficient way, I will get a multi-hash to use with the CGI:Explorer module.

    Please advice if my approach is wrong.

Re^2: Stuck with Creating Multi-Level hash
by CountZero (Bishop) on May 27, 2006 at 07:06 UTC
    What? No column to refer to which solved this problem already a long time ago? Are you feeling OK Merlyn? ;-)

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law