Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

These:

@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


Comment on Re: using / accessing nested hash/array references
Select or Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-07-14 03:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (254 votes), past polls