sunil9009 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $hashref = { 'Inventory' => { 'lb' => "abc", 'host' => [{ 'hostA' => { 'os' => "Linux",'locat +ion'=>"Dublin"}}, {'hostB' => {'os'=> "Windows",'locat +ion'=>"US"}}, {'hostC' => {'os'=>"Ubuntu",'locatio +n'=>"Germany"}} ] } } ;
Question 1: I just want the array values for names of the host @hosts = ('hostA','hostB','hostC');
Question 2: How can I push a new array value like push @hosts,$newvalue{'os'=>'Unix','location'=>'France'}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting array value from anonymous hash
by Athanasius (Archbishop) on Feb 13, 2014 at 14:41 UTC | |
by sunil9009 (Acolyte) on Feb 14, 2014 at 02:45 UTC | |
by Athanasius (Archbishop) on Feb 14, 2014 at 09:34 UTC | |
|
Re: getting array value from anonymous hash
by karlgoethebier (Abbot) on Feb 13, 2014 at 14:48 UTC | |
|
Re: getting array value from anonymous hash
by simmisam (Novice) on Feb 13, 2014 at 22:56 UTC |