Several small problems are tripping you:

&loginpage if $loggedin = 0;

You mean to compare with ==, not assign with = here. loginpage() will never be called because the assignment expression evaluates to 0, or false.

open (FILE, "users.dat");

You're not checking to see if the open succeeds. Getting the permissions right on a data file can be tricky, so it's worth dying or warning if you can't open the file.

if (&checklogin($userdef, $passdef) == 0) {

This is the second time you're calling this function. It's reasonable to assume you only need to call it once per invocation.

print header, start_html('Login Page'), hr;

This should be a comma. The rest of the HTML generating functions do nothing in void context and won't be printed to the screen.

if (param()) { $userdef = $query->param('user'); $passdef = $query->param('pass'); }

You're mixing the functional and object oriented interfaces to CGI here. Worse, I don't see where you've defined $query, so this is effectively useless.

If you turned on warnings with -w or the warnings module and enabled strict, Perl would let you know about most of these errors. Just run it from the command line:

perl -wc -Mdiagnostics mycgi.pl

You'll have a lot of things to fix, but if you're having trouble debugging, you need all the information you can get. This is how to let Perl help you.


In reply to Re: Debugging hell!! by chromatic
in thread Debugging hell!! by toonski

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.