If you use Win32::IE::Mechanize instead of WWW::Mechanize, which of course you can only do on Windows, because it uses the core of MS Internet Explorer, then you'll find it'll interpret Javascript and embed document.write() output in the produced "source". It's a neat way to have this kind of stuff handled automatically.