Does this work:
http://www.codeproject.com/internet/changeproxy1.asp
Ok it's not a perl solution, but it's the best I can come up with. Besides if you can figure how to use Perl to access INTERNET_OPTION_SETTINGS_CHANGED and INTERNET_OPTION_REFRESH you'll have what you need.