in reply to checking if new CGI worked

Your pushing onto a hash, when what you're actually trying to do is assign a value to a hash key. That might be valid, but it looks wrong. For maintainability, I'd try this (untested):
if ( $service_requests->param($checked_box) ) { $services{$product_id} = $service_requests->param($checked_box); } else { dienice("it's the services push"); }

Cheers,
Ovid

Update: Hmm... from what you say about trying to push onto an anonymous array, your syntax looks fine. Perhaps you should run this from the command line with the debugger? Since you are using the object-oriented method of calling CGI, this shouldn't be too difficult.

Otherwise, try printing the values directly from the loop.

Join the Perlmonks Setiathome Group or just go the the link and check out our stats.

Replies are listed 'Best First'.
RE: Re: checking if new CGI worked
by jptxs (Curate) on Sep 28, 2000 at 03:13 UTC

    actually, i'm trying to both assign a value to a hash key and push stuff into an anonymous array which is referenced by that hash key. $product_id becomes a key in %services which identifies an anonymous array whose elements are values from checkboxes that were checked on a web form which is parsed through $service_requests->param.

    at least, i think so :)

    -- I'm a solipsist, and so is everyone else. (think about it)

      Actually you are trying to do all that and also check for possible errors. Everything should work except the error check. The error check is getting the return from push, which is the number of new elements in the array.

      Which isn't testing what you are trying to do. OTOH what you are testing is something I don't think needs testing. The parameter has a value, else it wouldn't be tested.

      (Minor note. If you have a list of elements, eg from a multiple-select, all of them are going on that list in one fell swoop.)

      But your check for the name of the box having an "_" is wrong. You wind up there if any parameters do not match your pattern for a checkbox name. If this is truly an error then have your die message have the name of the parameter you are not accepting. Don't assume that this will be one of the first 4 parameters, or that you will remember later what the check is now.

      So I would drop the first error message, and rewrite the second to actually mean what has been tested.

      Oh, and in answer to your first question, try

      $services{$product_id}[$i];
      alternately you can get at the entire array as you did in your code. (This is just a hash of arrays.)

      See perlref for more.