Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Not able to retrieve hash value outside the function

by Preceptor (Deacon)
on Dec 21, 2015 at 10:23 UTC ( [id://1150846]=note: print w/replies, xml ) Need Help??


in reply to Not able to retrieve hash value outside the function

Your problem is this line:

%hash=@$row;

It _overwrites_ the hash with the current row, and is why you only have the last value. You should probably instead:

my ( $host, $ip ) = @$row; %hash{$host} = $ip;

I think that should do the trick

Replies are listed 'Best First'.
Re^2: Not able to retrieve hash value outside the function
by aniammu (Novice) on Dec 22, 2015 at 04:22 UTC

    Thank you . The code suggested by you worked as per my requirement.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2026-04-19 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    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.