Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: extact nested values

by McA (Priest)
on Mar 04, 2013 at 17:24 UTC ( #1021682=note: print w/replies, xml ) Need Help??

in reply to extact nested values


to be honest: I don't see the problem:

print $VAR1->{'press-release'}->[0]->{'PromoModuleTwo'}->[0]->{'RightC +oloumn'}->[0]->{'Tabs'}->[0]->{'TabName'}->[0], "\n"; print $VAR1->{'press-release'}->[0]->{'PromoModuleTwo'}->[0]->{'RightC +oloumn'}->[0]->{'Tabs'}->[1]->{'TabName'}->[0], "\n"; print Dumper($VAR1->{'press-release'}->[0]->{'PromoModuleTwo'}->[0]->{ +'RightColoumn'}->[0]->{'Tabs'}->[0]->{'Links'}), "\n"; print Dumper($VAR1->{'press-release'}->[0]->{'PromoModuleTwo'}->[0]->{ +'RightColoumn'}->[0]->{'Tabs'}->[1]->{'Links'}), "\n"; print Dumper($VAR1->{'press-release'}->[0]->{'PromoModuleOne'}->[0]->{ +'RightColoumn'}->[0]->{'Tabs'}->[0]->{'Links'}), "\n"; print Dumper($VAR1->{'press-release'}->[0]->{'PromoModuleOne'}->[0]->{ +'RightColoumn'}->[0]->{'Tabs'}->[1]->{'Links'}), "\n";

Have I missed something with the problem description?

Best regards

Replies are listed 'Best First'.
Re^2: extact nested values
by rajivreddy (Initiate) on Mar 04, 2013 at 17:55 UTC
    Hi MCA thanks for the reply but my problem is to print the values of the child elements of the link nodes iteratively and
    print $VAR1->{'press-release'}->[0]->{'PromoModuleTwo'}->[0]->{'RightC +oloumn'}->[0]->{'Tabs'}->[0]->{'TabName'}->[0], "\n";
    isn't printing anything

      Do you know how to iterate over a perl list?

      As the dumper output shows: The output of $VAR1->{'press-release'}->[0]->{'PromoModuleOne'}->[0]->{'RightColoumn'}->[0]->{'Tabs'}->[1]->{'Links'} is a list ref.

      So the following

      my $list_ref = $VAR1->{'press-release'}->[0]->{'PromoModuleOne'}->[0]- +>{'RightColoumn'}->[0]->{'Tabs'}->[1]->{'Links'}; foreach my $elem (@$list_ref) { print "Element by element", Dumper($elem), "\n"; }
      iterates over the list and you get every element which is by the way also a nested object. But with my solution shown it should be worth of a little transfer to address the child elements in every $elem. If this is not true then you have to learn some basics.

      Best regards

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1021682]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2017-06-23 21:13 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (555 votes). Check out past polls.