Hi Steve, On Monday 28 Feb 2011 21:47:30 steve park wrote: > I have a below program and I am not doing it right.
Is this the complete program? > Currently, only last ip pool is going in since I am putting them w/ key to > values(so only last one shows up when I print). OK. Have you localised a variable to its innermost scope? > > How can I aggregate and assign them to server_1 so that when I print below > will show up? > > server_1 > 10.1.1.1 > 10.1.1.2 > 10.1.1.3 > 10.1.1.4 > 10.1.1.5 > 192.168.1.1 > 192.168.1.2 Use a hash or an array reference. More comments on your code, below: > > > while ( <DATA> ) { do «while ( my $line = <DATA> ) {» and use «$line» instead. > my @array_ip; > chomp; > my ($swit,$server,$ip_range) = split; > > my ($b_real_ip,$b_ip, $e_ip) = $ip_range =~ > m#(\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; > } This should be a for loop, or maybe a map. > $HoA{ join('_',$swit,$server) } = \@ip_g; join('_',$swit,$server) is a complicated way to say: «"${swit}_$server"». Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ http://www.shlomifish.org/humour/ways_to_do_it.html An apple a day keeps the doctor away. Two apples a day will keep two doctors away. (-- one of Shlomi Fish's relatives) Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/