Sponsored Content
Top Forums Shell Programming and Scripting Perl hash of hashes anonymous array Post 302981588 by timj123 on Thursday 15th of September 2016 08:12:33 AM
Old 09-15-2016
Perl hash of hashes anonymous array

Hello experts. I'm having problems with a snippet of code.
I was hoping to get help/advice to correct.
A file that this script parses has changed to the point where
I can no longer use a scalar, it looks as though I need to
create an array for a hash of hashes below.

The first output of Dumper is from the actual script, the desired output
is what I think I need to assign. The problem with the script now is the
hash gets overwritten with the next valid value, I need to display all the values.
This is why I think I need an anonymous array within the hash of hashes.
I'm having issues with using push on this array. I can't seem to figure out the
correct syntax for this. I'll probably need help in dereferencing it as well, because
frankly I'm getting burnt out on this one.

Thanks guys


Code:
foreach my $z (sort keys %team) {
    for $y (@{$team{$z}}) {
      $_raw{$z}{$lookupph{$y}}=$y;
    }
}
print Dumper \%_raw;



-- Output --

'account' => {
                      'name01' => 'phone1',
                      'name02' => 'phone1',
                      'name03' => 'phone1',
                      'name04' => 'phone1',
                      'name05' => 'phone1',
                      'name06' => 'phone1',
                      'name07' => 'phone1',

					  
					  
Disired output

'account' => {
                      'name01' => ['phone1', 'phone2']
                      'name02' => ['phone1', 'phone2']
                      'name03' => ['phone1', 'phone2']
                      'name04' => ['phone1', 'phone2']
                      'name05' => ['phone1', 'phone2']
                      'name06' => ['phone1', 'phone2']
                      'name07' => ['phone1', 'phone2']



Also, how would I dereference the desired array reference?

Thanks in advanced.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl hashes "Can't use subscript on private hash"

This is driving me mad, where am I going wrong? The relevant segment of code: sub getndsybcons { my @servers=@{$_}; my @sybservers=@{$_}; my %results; foreach my $server(@servers) { my $biggestsyb; my $biggestsybval=0; ... (9 Replies)
Discussion started by: Smiling Dragon
9 Replies

2. Shell Programming and Scripting

Print Entire hash list (hash of hashes)

I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes). Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash. Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies

3. Shell Programming and Scripting

perl hash of hashes from database

hi there, I have some database output that looks like this SELECT nic_name,nic_duplex,nic_speed,nic_ip FROM network_table WHERE hostname = "server1" result is this (ive delimited with a pipe for ease of reading) bge0|full|1000|10.32.100.1 bge1|full|1000|11.12.101.7 ... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

4. Shell Programming and Scripting

PERL - printing a hash of hashes to screen

Hi there I have a hash of hashes made up of the following data bge0|100|half|10.36.100.21 bge1|1000|full|10.36.100.22 bge2|1000|full|10.36.100.23 which when i turn into a hash, would look like this inside the system bge0 -> nic_speed -> 100 nic_duplex -> half ... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

5. Shell Programming and Scripting

PERL - another quick hash of hashes question

Hi, sorry, two hash related questions in one day .. but this has got me a bit stuck. I have a mysql database table that kind of looks like this, the table is called "view1" and a snippet of that table (SELECT'ing just rows with serial number 0629AN1200) is below serial nic_name ... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

6. Shell Programming and Scripting

Need explanation on Anonymous hash in PERL!!

Hi, I have doubt regarding the Anonymous hash. For creating a object we are generally using Anonymous hash. My Doubt is: Why we are only using Anonymous hash?? Instead of Anonymous hash can we use global hash variable and take its reference for creating an object using same bless function??... (0 Replies)
Discussion started by: jatanig
0 Replies

7. Shell Programming and Scripting

Regarding anonymous hash in PERL

Hi, I have doubt regarding the Anonymous hash. For creating a object we are generally using Anonymous hash. My Doubt is: Why we are only using Anonymous hash?? Instead of Anonymous hash can we use global hash variable and take its reference for creating an object using same bless function??... (0 Replies)
Discussion started by: jatanig
0 Replies

8. Shell Programming and Scripting

perl: dereferencing a hash of hashes

Hi there, I am trying to dereference my hash of hashes but post dereferencing, it seems to lose its structure I am using Data::dumper to help me anaylise. This is the code im using to build the HoH, (data comes from a file). I have also performed a Dumper on the data structure before and after... (1 Reply)
Discussion started by: rethink
1 Replies

9. Shell Programming and Scripting

Perl : array of hashes help

Hi, I have array of hashes and each key has array like below. @array1 = ( { 'url' => , 'bill' => }, { 'url' => , 'bill' => }, { 'url' => , ... (0 Replies)
Discussion started by: ragilla
0 Replies

10. Shell Programming and Scripting

Compare values of hashes of hash for n number of hash in perl without sorting.

Hi, I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all . my %result ( $abc => { 'data_count' => '10', 'ID' => 'ABC122', } $def => { 'data_count' => '20', 'ID' => 'defASe', ... (1 Reply)
Discussion started by: asak
1 Replies
LOOPCTRL(8)						    Linux System Administration 					       LOOPCTRL(8)

NAME
loopctrl - configure isdnloop ISDN driver SYNOPSIS
loopctrl [-d Driver-Id] action options ... DESCRIPTION
loopctrl is used to setup the isdnloop ISDN driver. OPTIONS
-d Driver-Id selects the virtual S0 interface named by Driver-Id. Driver-Ids are defined during driver initialisation. See isdnloop(4) for a description of the syntax to be used for modularised and monolithic driver versions. This option must be used to identify the vir- tual S0 interface if more than one S0 interface is existent. If a single virtual S0 interface is used, it may be omitted. If using more than one virtual card, support for the other cards is enabled with the add action of loopctrl. Ids may not start with digits or small x, because these values are misinterpreted as numeric parameters by insmod. For loading the module, always the newest modu- tils package should be used to avoid problems during load. The following actions may be given to loopctrl. add [id] enables support for an additional virtual card in the driver. If id is missing, adds a card with an id given by the system. with id given, adds a card with an Id given by the user. Ids are checked against conflicts, and if a conflict happens, replaced by the sys- tem in the same manner as if no Id was supplied. leased on|off switches between normal (dialup) and leased-line mode. Leased-line mode is intended for usage with S64K-lines or - if both channels are used - for S02. These lines do not have a D-channel. When leased-line mode is enabled, the driver simulates incoming calls using special "phone-numbers" for calling and called address which are generated as follows: Calling number: LEASEDx where x is the internal slot-number of the S0 interface. This number starts with 0 for the first S0 interface and is incremented by one for every S0 interface configured using the add action. Called number: x where x is equal to the channel number of the calling S0 interface starting with 1. start protocol phone1 [phone2 phone3] starts the driver with the given D-channel protocol. If protocol is 1tr6, only phone1 has to be given. It is meant to be the base number of the virtual S0 interface to which the EAZ is appended. If protocol is dss1, phone1, phone2 and phone3 have to be given and represent the three MSNs of the virtual S0 interface. dump is available if the program is configured using the --enable-dump option only. The contents of internal driver variables is dumped on stdout. BUGS
This program and the isdnloop driver are ALPHA code. The main intention for this driver is for testing the link level and applications. AUTHOR
(C) 1997 by Fritz Elfert <fritz@isdn4linux.de> SEE ALSO
isdnctrl(8), isdnloop(4), isdninfo(4), isdnctrl(4), ttyI(4). isdn4k-utils-3.13 1999/09/06 LOOPCTRL(8)
All times are GMT -4. The time now is 09:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy