in reply to Re: Syntax Question Related to "join" on a Complex Data Structure
in thread Syntax Question Related to "join" on a Complex Data Structure
Well, I did look deeper, and I mostly understand what's going on now, but one thing does still surprise me.
say $transcripts{$transcript_ip}{$transcript_id}; + # gives me the hash reference of the lowest (3rd deep + hash) say %{ $transcripts{$transcript_ip}{$transcript_id} }; + # gives me that entire hash (key value pairs) say %{ $transcripts{$transcript_ip}{$transcript_id} }{@transcri +pts_columns}; # gives me my desired slice of that hash (key value p +airs) say keys { %{ $transcripts{$transcript_ip}{$transcript_id} }{@transcri +pts_columns} }; # gives me my desired slice of that hash (keys only) say @{ $transcripts{$transcript_ip}{$transcript_id} }{@transcri +pts_columns}; # gives me my desired slice of that hash (values only +)
What slightly surprised me is that the 3rd line above (with the leading %) gives the key value pairs and not just the values, but that made sense when I considered that I did essentially ask it to give me a hash and of course Perl would give a list of key value pairs when I do that. What still surprises me is that the last line simply by changing the leading % to a @ gives just the values to the list. Don't get me wrong though, that's darned convenient, and I'm really glad Perl does that.
I didn't even realize that's the same thing I had done before in the first line of code I gave in my original post until I went back and considered it more. For some reason that made complete sense to me at the time... or more likely I guessed, got lucky, and didn't inspect further because I didn't have to at the time. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Syntax Question Related to "join" on a Complex Data Structure
by haukex (Archbishop) on Oct 26, 2016 at 14:28 UTC | |
by BrowserUk (Patriarch) on Oct 26, 2016 at 16:18 UTC | |
by perldigious (Priest) on Oct 26, 2016 at 19:21 UTC | |
by perldigious (Priest) on Oct 26, 2016 at 15:01 UTC |