I am tring to sort the hash with values below is the code:
when i run this script getting these warnings. and in "system_ip" values are also not coming.sub mySort { $a =~ /(\d+)/; my $firstVal = $1; $b =~ /(\d+)/; my $secVal = $1; $firstVal <=> $secVal; } 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" ); foreach my $Value (sort mySort (values (%IP_Store))) { print "$Value\n"; print "System_ip = '$IP_Store{$Value}' \n"; #print "PDN-IP = '$Values' \n"; }
Thanks in advanceUEH1_system_ip Use of uninitialized value within %IP_Store in concatenation (.) or st +ring at C:\Users\Desktop\IP_test\test123.pl line 30. System_ip = '' UEH11_system_ip System_ip = '' UEH25_system_ip System_ip = '' UEH111_system_ip System_ip = '' Use of uninitialized value within %IP_Store in concatenation (.) or st +ring at C:\Users\Desktop\IP_test\test123.pl line 30.
In reply to Sort hash with values by Rahul Gupta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |