in reply to Array of Hashes Svn::Log confusion
Here is a debugger session, based on a made-up structure, similar to yours:
I have interjected comments starting with >>
so Now we know why "$revs[0]{date}" did not work.$ perl -dE 'my @revs=([{author=>"myid",date=>"2013-06-21"},2,3]); say +$revs[0]{date}' Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): my @revs=([{author=>"myid",date=>"2013-06-21"},2,3]); + say $revs[0]{date} >>>> Step into the initialization of the structure .... DB<1> s main::(-e:1): my @revs=([{author=>"myid",date=>"2013-06-21"},2,3]); + say $revs[0]{date} >>>>>*** Looking at the whole structure (Not a good idea if it is larg +e) DB<1> x @revs 0 ARRAY(0x1765270) 0 HASH(0x1765210) 'author' => 'myid' 'date' => '2013-06-21' 1 2 2 3 >>>>> Slow dive - We know @revs is an ARRAY - let us see what TYPE the + first (0) element is : DB<2> x ref $revs[0] 0 'ARRAY' >>>> OK - so it is an 'ARRAY' - lets examine the TYPE of the first (0) + index. DB<7> x ref $revs[0][0] 0 'HASH' >>> Aha - so $revs[0][0] is a HASHREF - lets see what KEYS are availab +le... DB<9> x keys %{ $revs[0][0] } 0 'date' 1 'author' >>>> Now we could do another "ref', but assuming this will result in a + target value, we simply try a key: DB<10> x $revs[0][0]{date} 0 '2013-06-21' >>> end the debug session with 'quit' DB<11> q
"The trouble with the Internet is that it's replacing masturbation as a leisure activity."
-- Patrick Murray
|
|---|