in reply to assigning hash key to reference of array question

I think this what you are looking for:
use strict; use warnings; my %HoA; while ( <DATA> ) { my @array_ip; chomp; my ($swit,$server,$ip_range) = split; my ($b_real_ip,$b_ip, $temp, $e_ip) = $ip_range =~ m#(\d+\.\d+\ +.\d+\.)(\d+)\-(\d+\.\d+\.\d+\.)(\d+)#; my $b_ip_copy = $b_ip; my @ip_g; while ( $b_ip_copy <= $e_ip) { my $b_ip_final = join('',$b_real_ip,$b_ip_copy); push @ip_g , $b_ip_final; ++$b_ip_copy; } $HoA{ join('_',$swit,$server,$b_real_ip) } = \@ip_g; } for my $key (sort keys %HoA) { for my $key2 (@{ $HoA{ $key } }) { print "$key\t"; print "$key2\n"; } print "\n"; } __DATA__ server 1 10.1.1.1-10.1.1.5 server 2 192.168.1.1-192.168.1.5 server 1 192.168.1.1-192.168.1.2