![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Read csv into Hash array? | kinmak | Shell Programming and Scripting | 1 | 05-07-2008 10:35 AM |
| perl array question from going through hash | hankooknara | Shell Programming and Scripting | 2 | 07-29-2007 09:53 PM |
| hash,array and perl | new2ss | Shell Programming and Scripting | 3 | 05-23-2007 11:30 AM |
| md5 hash a string or char array in SCO | jcarter2333 | High Level Programming | 5 | 02-08-2007 04:09 PM |
| getting data list into a hash array | topcat8 | Shell Programming and Scripting | 5 | 03-09-2004 12:02 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hash within array, within hash, within array...
I have a little problem. To keep a configuration simple, I've exceeded my perl knowledge. :-) I've worked with multi-dimentional arrays before, but this one has me beat:
Code:
@info = (
{
'defval' => 'abc'
'stats' = (
{ 'name' => 'a', },
{ 'name' => 'b', },
),
},
{
'defval' => 'def'
'stats' = (
{ 'name' => 'd', },
{ 'name' => 'e', },
),
},
);
my @infolist = $info[0]->{stats}; # I have a feeling this is where I'm going wrong...
print $infolist[0]->{name}; # <-- works!
print $infolist[1]->{name}; # <-- does not!
Thanks, js. |
|
||||
|
I have no idea why you said one of the statements worked, because your entire snippet was full of errors, and I confirmed that by running on my machine with compilation errors.
Not sure whether my modified version is what you intended. Code:
@info = (
{
'defval' => 'abc',
'stats' => [
{ 'name' => 'a', },
{ 'name' => 'b', },
],
},
{
'defval' => 'def',
'stats' => [
{ 'name' => 'd', },
{ 'name' => 'e', },
],
},
);
my $r_infolist = $info[0]->{stats};
print $r_infolist->[0]{name}; # <-- a
print $r_infolist->[1]{name}; # <-- b
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|