Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Pulling a hash value in a data structure

by toolic (Bishop)
on Jan 25, 2011 at 18:27 UTC ( [id://884201]=note: print w/replies, xml ) Need Help??


in reply to Pulling a hash value in a data structure

Instead it returns nothing.
If you use strict and warnings you will get something -- an error message.

wfsp is correct. Dumpvalue may also be useful when you're trying to remember how to dereference because it shows the numeric indexes of arrays (How can I visualize my complex data structure?):

use warnings; use strict; use Dumpvalue; my $res1 = { 'report' => [ '2011-01-25 10:30:50', { 'AntiVir' => 'Eicar-Test-Signature' } ] }; Dumpvalue->new->dumpValue($res1); __END__ 'report' => ARRAY(0x60b0f0) 0 '2011-01-25 10:30:50' 1 HASH(0x60b220) 'AntiVir' => 'Eicar-Test-Signature'

An alternate approach is to use Data::Diver:

use warnings; use strict; use Data::Diver qw(Dive); my $res1 = { 'report' => [ '2011-01-25 10:30:50', { 'AntiVir' => 'Eicar-Test-Signature' } ] }; print Dive( $res1, qw( report 0 ) ), "\n"; print Dive( $res1, qw( report 1 AntiVir ) ), "\n"; __END__ 2011-01-25 10:30:50 Eicar-Test-Signature

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2025-11-17 00:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (72 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.