in reply to Hash of arrays of hashes
A simple sort is used above. In real life, your sort sub may be complicated if you want to preserve true numeric order in the port.my %INPUT_DATA = ( 'DEVICE1_NAME' => { '1/1/5/40' => { 'ACTUAL' => { 'SVC' => '239', 'SPTM' => '112', }, 'NEW' => { 'SVC' => '239', 'SPTM' => '183', }, }, }, ... # Now, you can use: #....set $device_name #.... foreach my $current_port ( sort keys %{$INPUT_DATA{$device_name}} ) { my @CURRENT_PORT_STATUS = print( "show xdsl operational\-data line + $current_port detail"); }
Update: If you really wanted to keep the current data structure (in case it came from outside your control), you will need to process every other element : i.e. skip the hashref, process only the "key" which is a scalar.
To do this, the first thing in the "for loop" should be:
next unless ref $current_port eq ""; # skip if $current port is NO +T a scalar.
"I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
-- Dr. Cox, Scrubs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash of arrays of hashes
by AnomalousMonk (Archbishop) on Apr 14, 2013 at 20:24 UTC | |
by NetWallah (Canon) on Apr 14, 2013 at 21:09 UTC | |
by AnomalousMonk (Archbishop) on Apr 14, 2013 at 22:42 UTC | |
by Anonymous Monk on Apr 15, 2013 at 00:43 UTC | |
|
Re^2: Hash of arrays of hashes
by bArriaM (Novice) on Apr 15, 2013 at 13:19 UTC |