The stupid question is the question not asked | |
PerlMonks |
Re: Could you look over my completed (but not working) short .cgi script?by GrandFather (Saint) |
on May 31, 2014 at 22:34 UTC ( [id://1088143]=note: print w/replies, xml ) | Need Help?? |
Using strictures (use strict; use warnings;) is excellent and something you should always do. Batch declaring variables negates the most valuable diagnostic that strict provides. In fact what you wreck is exactly what your comment describes as the reason for using strict! Consider this fragment of your code:
Do you see anything wrong there? How about if we rewrite it this way and run it:
Now you get an error: Global symbol "@basket" requires explicit package name which is strict's way of saying "I haven't seen the variable @basket before". In other words, @basket is undefined. So, what do you expect the cookie value to be? What it will be is an empty string, but if you intended that you should write that. If you didn't intend that, batch declaring variables has masked exactly the sort of bug strict should alert you to.
Perl is the programming world's equivalent of English
In Section
Seekers of Perl Wisdom
|
|