--- "RDWest Sr." <[EMAIL PROTECTED]> wrote:
> hi yall,
> maybe i been up too long... i'm confused with this... script works
>fine but
> returns errors with use strict...
> could someone plz explain what i'm doing wrong?
> tx
'use strict' will, amongst other things, force you to predeclare all variables (well,
almost all)
that you use before you actually use them. For example:
#!/usr/bin/perl
use strict;
use CGI qw/:standard/;
$username = param( 'username' );
That will not compile because you have attempted to assign a value to $username
without declaring
it. To get around this:
my $username = param( 'username' );
Or:
my $username;
$username = param( 'username' );
Why do this? A couple of weeks ago, I was working on a 2,000 line program that
someone else
wrote, but they didn't use strict. It took me over half an hour to figure out that
one of the
variable names had been misspelled on one of the lines. Had the 'strict' pragma been
used, the
program would not even have compiled. It would instantly have told me that the
misspelled
variable wasn't declared and I could have gone it to fix it. Unfortunately, once
programs get
that large, retro-fitting them to use strict is very difficult.
I thought about fixing up your code, but it has some serious problems. You have
borrowed some
very, very broken form-handling code from some book or Web site. For a thorough
explanation of
why that code is broken, read
http://www.easystreet.com/~ovid/cgi_course/lesson_two/lesson_two.html. I'd summarize
the details
for you, but there are so many problems with that code that I felt a link was more
appropriate.
Please don't take any of this personally. I realize that you are new to Perl and I'm
just hoping
to point you in the right direction.
Cheers,
Curtis Poe
=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/