#open connection # some code here and then: while (my $address=@address) { &addressExists($address); # other stuff } #close connection