If I am understanding you correctly that is -
1. Copy the html content into a variable
2. Do regex substitution to change your form action inside that variable
3. Update the mechanize object with that variable
For example -
CPAN::Forum
WWW-Mechanize - Re: Dinamically setting form action