in reply to Alternative 2 WWW-Mechanize with JavaScript ?
Nowadays there is also WWW::Scripter, with a JavaScript plugin. But I have no experience with that one.