Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Converting array of hash references to hash

by anirudh.agarwal (Novice)
on Apr 22, 2013 at 13:14 UTC ( #1029864=note: print w/replies, xml ) Need Help??


in reply to Re: Converting array of hash references to hash
in thread Converting array of hash references to hash

What actually happens in your case is, the value of deviceIp, say, 172.16.133.56 changes to 172.16 . Is it because that perl is taking it as an integer?

Replies are listed 'Best First'.
Re^3: Converting array of hash references to hash
by hdb (Prior) on Apr 22, 2013 at 13:22 UTC

    I do not understand. If I run:

    use strict; use warnings; use Data::Dumper; my $ams_hosts = [ { 'domainId' => '1', 'deviceIp' => '172.16.133.56', 'deviceType' => 3, 'deviceName' => 'AMS' }, { 'domainId' => '1', 'deviceIp' => '172.16.133.57', 'deviceType' => 3, 'deviceName' => 'ams_57' } ]; my %ams_ips_hash = map { $_->{'deviceIp'} => 1 } @{$ams_hosts}; print Dumper( \%ams_ips_hash );

    I get

    $VAR1 = { '172.16.133.56' => 1, '172.16.133.57' => 1 };

    Can you clarify what you mean please?