Without going through your code in great detail, I've a few points -
1) I'm not too sure if you can authenticate the way you are doing, using LWP::UserAgent. Also, you are calling the subroutine login with username
as parameters, but nowhere in sub login
you are using them.
is a module which is used to automate tasks related to web page automation, authentication etc. You can have a look at it.
3) You need to post more detailed information about what you want to achieve. For eg. what is the content of the page you're leeching, what information you are extracting, what action you want to automate etc. Examples would be great.
4) Do you get any error on running your script? If yes, please post the complete error. Else state whatever is happening on running the script.