"...and have it log into my webmail automatically..."

And then what? Do you want 'the thing that logged you in' to just disappear and allow you access WebMail via your browser. Probably not going to work. Do you want to scrape each screen and deliver the contents via some proxy? That would work, but it seems uneccesary. I would definitely use WWW::Mechanize for that, but all of that work just so you can be lazy and not have to enter a password ... the payoff just isn't there for me. However, if you want to do this for your own education ... speed on! We will be glad to help you if you get stuck.

Update: code review time :)

  1. tuck your usage string into a sub, and call that sub instead of copying and pasting code. Remember, real coders use abstraction instead of copy-paste. But ... you can't supply a usage like that for a CGI script. Instead, one typically reports which required fields were missing (putting the message in red right next to the form field is a plus).
  2. your tests don't check for parameters that might only contain white space. A user name of " " is valid according to your code. Try something like:
    my $username = trim(param('username')); sub trim { my $dirty = shift; $dirty =~ s/^\s*//g; # remove leading whitespace $dirty =~ s/\s*$//g; # remove trailing whitespace return $dirty || ''; # return empty string if $dirty is undef }
  3. using multiple prints is a waste of typing, consider this:
    print q|<html> <head> <title>Logging in ...</title> </head> <body> |;
    looks much nicer, but now consider using CGI.pm:
    use CGI qw(:standard); print header, start_html('Logging in ...');
    I also recommend using HTML::Template, but you might not be ready for that yet. (it comes with it's own learning curve)
Oh, and welcome to the Monastery. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: CGI Auto Login by jeffa
in thread CGI Auto Login by cdubbs94

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.