Hi, I'm trying to update a device's configuration by using a strange hash of arrays of hashes. It's not really beautiful but it's the best way I found out so far. The HASH looks like this:

my %INPUT_DATA = ( 'DEVICE1_NAME' => [ '1/1/5/40' => { 'ACTUAL' => { 'SVC' => '239', 'SPTM' => '112', }, 'NEW' => { 'SVC' => '239', 'SPTM' => '183', }, }, ], 'DEVICE2_NAME' => [ '1/1/5/30' => { 'ACTUAL' => { 'SVC' => '239', 'SPTM' => '112', }, 'NEW' => { 'SVC' => '239', 'SPTM' => '183', }, }, '1/1/7/1' => { 'ACTUAL' => { 'SVC' => '124', 'SPTM' => '112', }, 'NEW' => { 'SVC' => '124', 'SPTM' => '183', }, }, '1/1/7/23' => { 'ACTUAL' => { 'SVC' => '194', 'SPTM' => '112', }, 'NEW' => { 'SVC' => '194', 'SPTM' => '183', }, }, ], );

Now, when I try some commands, the result looks like this (half good):

leg:isadmin># show xdsl operational-data line 1/1/5/30 detail leg:isadmin># show xdsl operational-data line HASH(0x53e228) detail leg:isadmin># show xdsl operational-data line 1/1/7/1 detail leg:isadmin># show xdsl operational-data line HASH(0x53e2e8) detail leg:isadmin># show xdsl operational-data line 1/1/7/23 detail leg:isadmin># show xdsl operational-data line HASH(0x53e3a8) detail

You see, the first command is good, then I have a reference to a hash, then a good command, etc.

Here's the output from Dumper:

$VAR1 = 'DEVICE1_NAME'; $VAR2 = [ '1/1/5/40', { 'NEW' => { 'SVC' => '239', 'SPTM' => '183' }, 'ACTUAL' => { 'SVC' => '239', 'SPTM' => '112' } } ]; $VAR3 = 'DEVICE2_NAME'; $VAR4 = [ '1/1/5/30', { 'NEW' => { 'SVC' => '239', 'SPTM' => '183' }, 'ACTUAL' => { 'SVC' => '239', 'SPTM' => '112' } }, '1/1/7/1', { 'NEW' => { 'SVC' => '124', 'SPTM' => '183' }, 'ACTUAL' => { 'SVC' => '124', 'SPTM' => '112' } }, '1/1/7/23', { 'NEW' => { 'SVC' => '194', 'SPTM' => '183' }, 'ACTUAL' => { 'SVC' => '194', 'SPTM' => '112' } } ];

Hope someone can help! Thanks!

EDIT: here's the loop I use to go through the whole hash and print a command:

foreach my $current_port ( @{$INPUT_DATA{$device_name}} ) { my @CURRENT_PORT_STATUS = $session->cmd( "show xdsl operational\-d +ata line $current_port detail" ); }

In reply to Hash of arrays of hashes by bArriaM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.