Helen,

The part up front is this, correct?

elsif ($choice eq "update") # update shopping cart { update_cart ($cart_ref, param("quantity")); $page .= format_cart_html ($cart_ref, 1); }

Your upfront conditional calls the update_cart method (subroutine if you prefer), which in turn calls the method update.

sub update_cart { my ($cart_ref, $item_id, $qty) = @_; update ($cart_ref->{$item_id}->{qty} = $qty); }

That piece of code makes the assignment $cart_ref->{$item_id}->{qty} = $qty and then calls update with the value of $cart_ref->{$item_id}->{qty}. What I still don't see in your scratchpad is the subroutine "update." Is it part of your WebDB module or did you forget to include it. Somewhere in your code should be something like this:

sub update { # a bunch of code }

update: And err, you call update_cart and send it only two vars, $cart_ref and quantity; however, in the update_cart method, you say there are three parameters, $cart_ref, $item_id and $qty - thats a problem. -derby


In reply to Re: Re: Re: Need some help to review code by derby
in thread Need some help to review code by hbradshaw

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.