One isssue being pointed out is that your subroutines get() and login() are defined within your SUBMIT() subroutine. I can't think of a good reason for that. Your indentation makes it difficult to see that that is whats going on. Try indenting like this: (i copied your SUBMIT function, and just indented it.)
sub SUBMIT { my $login = 1; my $ua = LWP::UserAgent->new(%uaoptions); $ua->cookie_jar( {} ); if ($login) { &login; } my $logintest= get("http://www.site.com/"); if ($logintest =~ m!you are now logged!sim) { } else { print "Bad username or password."; exit; }
With that indentation, its easy to see that you are missing the closing '}' in the else, which is why you need the final one at the end of your code.
Another issue i'd like to bring up is that you are not useing strict or warnings, which will only bite you in the end.

Also, you could benefit from passing variables into your subroutines, instead of having globals.

I don't mean to bash your code, for the most part it looks like you're on the right track. As you said, you're pretty new to this, and myself and the other comments are trying to keep you from getting into some bad habits that will hinder you in the end.

Good luck, hopefully we can be some help to you.


I use the most powerful debugger available: print!

In reply to Re: Just between you, me and subroutines by shemp
in thread Just between you, me and subroutines by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.