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

Re: using / accessing nested hash/array references

by state-o-dis-array (Hermit)
on Jan 18, 2011 at 23:30 UTC ( #883014=note: print w/replies, xml ) Need Help??

in reply to using / accessing nested hash/array references

@results = &get_list(); $hostresults[0] = &get_list();
are not equivalent. You have encountered a context issue, the first line above is list context, the second is scalar, in other words, $hostresults[0] is not an array as I think you are expecting. I think what you would want to do is change the second line to something like:
$hostresults[$i] = \@results;
Then $hostresults[0] is a reference to your first data set.

You might want to look at perldsc and perlref

Replies are listed 'Best First'.
Re^2: using / accessing nested hash/array references
by tspfwj (Initiate) on Jan 18, 2011 at 23:40 UTC
    I changed the line to
    $hostresults[0] = \@{&get_list()};
    and I am still receiving the scalar error. I have experimented with initializing like
    my @hostresults = (\@result1,\@result2); #or my @hostresults = (@result1,@result2);
    but I still received errors. My attempts would have been with the same context though. The right side sub returns the array of hash references which is why I left in the line above in my original example. My hope was to show what was happening outside of my context or syntax errors. Thank you
      Sorry, I was kind of hoping that having changed how you are assigning to $hostresults[0] that you might take that as a clue to look at how you are accessing it. Anonyrnous Monk provides a valuable suggestion in referring you to Data::Dumper. Also, have you taken time to check out the links I provided? I think that they will be helpful to you.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2018-06-21 05:23 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.