Adding From elements....

Discussion in 'Perl Misc' started by dbmeyers23@yahoo.com, Feb 11, 2005.

  1. Guest

    All,

    I have a form with about 150 fields that I would like to have added
    together automatically and the value placed into a new variable.
    Below, you will see my @list. Below that, I'm going through @list and
    only printing those values which have data (thanks to google.groups).

    What I would like to do now, and I'm struggling a bit to do is add
    these quantities together....so anywhere I see "addquantity", I would
    like to keep adding the values until done..then place them in a new
    variable. Any hints??




    my @list = (

    [addzip2 => 'Additional Zip 2' ],
    [addquantity2 => 'Additional Quantity 2' ],
    [addzip3 => 'Additional Zip 3' ],
    [addquantity3 => 'Additional Quantity 3' ],
    [addzip4 => 'Additional Zip 4' ],
    [addquantity4 => 'Additional Quantity 4' ],
    [addzip5 => 'Additional Zip 5' ],
    [addquantity5 => 'Additional Quantity 5' ],
    [addzip6 => 'Additional Zip 6' ],
    [addquantity6 => 'Additional Quantity 6' ],
    );


    for (@labels) {

    if ( $query->param( $$_[0] ) ) {

    print "$$_[1]: ", $query->param( $$_[0] ), "<br>";
    print INT_EMAIL "$$_[1]: ", $query->param( $$_[0] ), "\n";

    }
    }
    , Feb 11, 2005
    #1
    1. Advertising

  2. <> wrote:


    > What I would like to do now, and I'm struggling a bit to do is add
    > these quantities together



    > Any hints??



    Perl's addition operator is the plus sign (+).


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 11, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wolfgang Lipp
    Replies:
    1
    Views:
    391
    Patrick TJ McPhee
    Jan 30, 2004
  2. Wolfgang Lipp
    Replies:
    0
    Views:
    465
    Wolfgang Lipp
    Jan 28, 2004
  3. Jyrki Keisala

    Elements within elements

    Jyrki Keisala, Jun 8, 2005, in forum: XML
    Replies:
    5
    Views:
    420
    William Park
    Jun 15, 2005
  4. Billy
    Replies:
    4
    Views:
    344
    Billy
    Sep 12, 2005
  5. Gerald Aichholzer
    Replies:
    2
    Views:
    2,482
    Gerald Aichholzer
    Jun 27, 2006
Loading...

Share This Page