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

Kenneth Thompson kthompson at omnihotels.com
Fri Sep 30 12:38:25 PDT 2005


So... 

Wouldn't this work?

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

Since it ignores the falses (0 and undef), it would fall through to the
last choice, which would be your default?

-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Jay Hannah
Sent: Tuesday, September 20, 2005 10:15 AM
To: omaha-pm at pm.org
Subject: [Omaha.pm] Ow!! || bit me

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

_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm



More information about the Omaha-pm mailing list