http://www.perlmonks.org?node_id=1028634

bArriaM has asked for the wisdom of the Perl Monks concerning the following question:

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" ); }