Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Print elements of hash references

by Anonymous Monk
on Mar 31, 2012 at 18:21 UTC ( #962786=note: print w/replies, xml ) Need Help??


in reply to Re: Print elements of hash references
in thread Print elements of hash references

Thanks for that I will have a look. Can you tell me how to do it with this particular example? Those are (I think) array references and not array of arays or hash or arrays etc that the perldsc have.

  • Comment on Re^2: Print elements of hash references

Replies are listed 'Best First'.
Re^3: Print elements of hash references
by chromatic (Archbishop) on Mar 31, 2012 at 18:33 UTC

    Looks like you have a hash of hashes of arrays of arrays. The principle is the same no matter how far you nest.

Re^3: Print elements of hash references
by Happy-the-monk (Abbot) on Mar 31, 2012 at 18:37 UTC

    push @{$An{$n}->{b}} , $bb[$idx];

    let's see, if perldsc did not make it clear enough, maybe perldata and perllol will help a bit further?
    Anyway, looking for "references" and Hashes of Hashes (HoH) and Hashes of Arrays (HoA) in the documentation and also on this site may help you along.

    What you are doing is pushing onto an array reference that is inside a hash (%An) of hashes the value in position ($idx) of an array (@bb).

    I am a little curious though: If you don't know what you are doing, why are you doing it?

    To see the results, do try use Data::Dumper;print Dumper \%An;

    Cheers, Sören

Re^3: Print elements of hash references
by RichardK (Parson) on Mar 31, 2012 at 18:33 UTC

    where did $An get declared?

    Well, I don't really understand the code fragment you posted but, maybe

     print $An->{id}[0];

    Try using Data::Dumper to see the contents of $An

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://962786]
help
Chatterbox?
[choroba]: timestamps are hard
[1nickt]: not all all yet
[1nickt]: the stable subversion of each major version on the platform I have in my hands most of the day
[Tux]: choroba can't you up the default stack size to 17?
[1nickt]: and I will maybe add the other subversions
[1nickt]: I am on MacOSX and there is a sore lack of testing resources for CPANTS I think
[choroba]: Tux Why? It works for me with 16 :-)
[Tux]: and the defailt is 15?
[choroba]: sorry, typo. Works for me with 15 which is the default

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-09-19 20:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (228 votes). Check out past polls.

    Notices?