## iterate through record foreach(@DATA) { ($hostid, $time, $get, $post, $currconn) = split(/\t/); ## match against the server list and process accordingly foreach $server (@servers) { chomp $server; next unless $hostid eq $SERVER{$server}; open TMP, ">>/tmp/$server.tmp"; $ENV{"FILENAME"} = "/tmp/$server\.tmp"; ## more here... close TMP; ## done with this record, move on last; } }