my $subnet = "40"; for(1..239){ chomp; my $ip = "10.1.$subnet.$_"; . . }