[Omaha.pm] Ow!! || bit me

Jay Hannah jhannah at omnihotels.com
Tue Sep 20 08:15:02 PDT 2005


Code:

  $res->set_child_qty    ($cookie->{child_qty} ||
$q->param('child_qty'));


When:

  $cookie->{child_qty}     is 0
       and
  $q->param('child_qty')   is undef


Then:

  I'm running   $res->set_child_qty(undef)

which is NOT what I wanted.


Doh! I need Perl 6's // operator! -grin-


New code:

  if (defined $cookie->{child_qty}) {
     $res->set_child_qty($cookie->{child_qty}) 
  } else {
     $res->set_child_qty($q->param('child_qty'))      
  }


Eww... Long and ugly. But it does do what I want and 0 is a valid value
for child_qty. 

$live && $learn++;

j



More information about the Omaha-pm mailing list