in reply to Sort hash with values
Output:#!/usr/bin/perl use strict; use warnings; use Socket qw /inet_aton inet_ntoa/; my %ip_store = ( "11.0.0.1" => "UEH1_system_ip", "11.0.0.11" => "UEH11_system_ip", "11.0.0.3" => "UEH25_system_ip", "11.0.0.25" => "UEH111_system_ip" ); my @sorted = map {inet_ntoa $_} sort map {inet_aton $_} keys %ip_store +; foreach my $ip (@sorted) { print "$ip\n"; print "System_ip = '$ip_store{$ip}' \n"; }
ChrisC:\Old_Data\perlp>perl t9.pl 11.0.0.1 System_ip = 'UEH1_system_ip' 11.0.0.3 System_ip = 'UEH25_system_ip' 11.0.0.11 System_ip = 'UEH11_system_ip' 11.0.0.25 System_ip = 'UEH111_system_ip'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort hash with values
by sammy_01 (Initiate) on Jun 24, 2013 at 06:36 UTC | |
by AnomalousMonk (Archbishop) on Jun 24, 2013 at 19:44 UTC | |
by sammy_01 (Initiate) on Jun 25, 2013 at 10:53 UTC |