Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Access elements in the nested array

by Nikhil Jain (Monk)
on May 26, 2011 at 09:09 UTC ( [id://906776]=note: print w/replies, xml ) Need Help??


in reply to Access elements in the nested array

It would be nice if you use modules like Config::Tiny , Config::IniFiles , Config::INI::Reader for reading ini files.

I am troubling to access the nested array elements,

try something like,

use strict; use warnings; my @myfiles = ( ['INI_1','INI_2', ['VALUE_1'], ['VALUE_2'], ['VALUE_3'] ], ['INI_3','INI_4', ['VALUE_1'], ['VALUE_2'], ['VALUE_3'] ] ); foreach my $ini (@myfiles) { foreach my $nested_level (@{$ini}){ if(ref($nested_level) eq 'ARRAY'){ my @values = @{$nested_level}; print"@values\n"; }else{ print"$nested_level\n"; } } }
Output: INI_1 INI_2 VALUE_1 VALUE_2 VALUE_3 INI_3 INI_4 VALUE_1 VALUE_2 VALUE_3

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://906776]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found