use NetAddr::IP; use Net::Ping::External qw/ping/; ping( 'host' => $_ ) for map { $_->addr } NetAddr::IP->new("10.0.0.0/24")->hostenum;