$ipnumber ="128.135.75."; @iparray = map $ipnumber.$_,1..254 ; # no chomps needed ... foreach my $host (@iparray) { if ( $p->ping($host)){ print "$host is alive\n"; } } ...