I'll suggest something other than DynDNS, and actually use Perl in the process. I keep an external web server with this simple CGI:
use CGI 'header';
Then you can query that CGI from inside your network and get the IP address. That information is stored on the router itself, of course, but it isn't necessarily easy to get at automatically.
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.