RE: a little help...




"my $MyIpAddrInfo = \%MIAI;" makes $MyIpAddrInfo a reference to the
%MIAI hash. That is why you can't print it directly.

If you want to treat $MyIpAddrInfo like the hash it refers to, you have
to dereference it by prefacing it with the '%' (see example below). The
brackets are usually optional, but some people like me just use them all
the time to avoid certain problems with more complicated data
structures.

my @keys = sort keys %{$MyIpAddrInfo};

You can also indirectly access the members of the hash by using the ->
operator, so:

$MyIpAddrInfo->{ip}

is the same as

${$MyIpAddrInfo}{ip}

is the same as

$MIAI{ip}



-----Original Message-----
From: FamiLink Admin [mailto:webmaster@xxxxxxxxxxxx]
Sent: Saturday, October 01, 2005 3:04 PM
To: Wagner, David --- Senior Programmer Analyst --- WGO
Cc: beginners@xxxxxxxx
Subject: Re: a little help...

David,
Thank you for your help! I am trying to get this to work. Can you tell
me
what my $MyIpAddrInfo = \%MIAI; does? I am getting

HASH(0x8133528)

for $MyIpAddrInfo if I print it out after the:

$MyIpAddrInfo->{$ip}++;


Ryan Lamberton

<snip>

.



Relevant Pages

  • Re: Annoying HASH(0x...) in Output
    ... '_friends' for a hash key, and 'warnings' won't say that your code ... # dereference the array from the hash ... push @$friendsref, $newfriend; ...
    (perl.beginners)
  • Re: Question about arrays of hashes
    ... funky dereferencing thing while changing the context to hash. ... It seems like an odd OO module design that would lead me to ... with things like the "stat" function, but the stat function isn't OO. ... I would just get the $hashref and dereference ...
    (comp.lang.perl.misc)
  • Re: GetOptions with dynamic set of options
    ... the arguments for GetOptions, ... you can get a reference to your target hash: ... reference as a parameter, you could use that parameter to get ... you can use the curly-brace notation to dereference the entire ...
    (perl.beginners)
  • Incrementing variable names in a loop?
    ... There is a little more to the problem in the fact that the signals array ... variables by looking them up in a hash. ... Problem is when I create this variable with an incrementing name, ... Dereference a variable within a variable ...
    (comp.lang.ruby)
  • Re: How to implement a Hash Table in C
    ... You can read all about hash tables in my book, ... As for the derefencing null pointer, that will happen if the constructor fails, and return NULL. ... The normal thing when you an error such as dereference of a null is to say "your code derererences a null" rather than to talk airly about "catastropic behaviour" in an arrogant manner. ...
    (comp.lang.c)