Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Dereferencing a portion of a hash

by THRAK (Monk)
on Feb 18, 2005 at 17:12 UTC ( [id://432422]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Dereferencing a portion of a hash
in thread Dereferencing a portion of a hash

Thanks, I see that now. Although I don't understand how it is a reference at that point. Prior to that point it is declared and I've simply been populating it via:
my %report_data; ... $report_data{$domain}{$provider}{ok}++;

Replies are listed 'Best First'.
Re^5: Dereferencing a portion of a hash
by RazorbladeBidet (Friar) on Feb 18, 2005 at 17:22 UTC
    You don't understand how $report_data{$domain}{$provider} is a reference?

    If not, if you were to define things all at once it would be like this:

    my %report_data = ( $domain => { $provider => { 'error' => '0', ... # other stuff here } } }


    The reason it's a reference is because you have a scalar value (hash value $report_data{$domain}) pointing to a hash reference.

    From perldoc -f perldata:


    ...
    All data in Perl is a scalar, an array of scalars, or a hash of scalars
    ...
    Although a scalar may not directly hold multiple values, it may contain a reference to an array or hash which in turn contains multiple values.
    ...


    A hash isn't a scalar, it's a hash, but a reference is a scalar, so it can hold that in the value of the hash where the key is $provider.
    --------------
    It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-24 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found