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.