$net="192.168.4."; $counter=10; ... $ip=$net.$counter; ... while ( $counter <= 14 ) { ... open(LOGF,">>",$logpath . $ip); ... while ( ) { ... $ip=$net.$counter; ... } } $counter++; }