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:

#prevent Perl from creating undeclared variables use strict; #declare variables and assign variables my ($item, $C_basket, @basket); #make cookies $C_basket = cookie( -name => "Basket", -value => "@basket", -path => "../../cgi-bin/chap11" );

Do you see anything wrong there? How about if we rewrite it this way and run it:

use strict; #make cookies my $C_basket = cookie( -name => "Basket", -value => "@basket", -path => "../../cgi-bin/chap11" );

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 reply to Re: Could you look over my completed (but not working) short .cgi script? by GrandFather
in thread Could you look over my completed (but not working) short .cgi script? by StarRice

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.