Yup, I already found that inserting an initial sleep would resolve the problem, but I couldn't understand why; now I do! Thanks a million.
The code segment is part of the DnsPixie.pl program which you can find at http://www.cpan.org/scripts/. It's intended to update dynamic DNS records when the host address changes. And it actually works well on other (Ubuntu, OpenBSD, Windows-XP, etc.) platforms.
So I guess I need to force a cache refresh at each pass? Perhaps by a call to gethostbyname? Or .. ??