You should switch to WWW::Mechanize, which is
a subclass of LWP::UserAgent. WWW::Mechanize provides
methods which abstract away cumbersome items like having to
know what the name of a form or submit button is - it also
provides a cookie jar and history of visted pages. See
the documentation for examples.