[Omaha.pm] Another || quickie

Jay Hannah jay at jays.net
Mon Aug 22 19:55:18 PDT 2005


On Aug 19, 2005, at 12:57 PM, Kenneth Thompson wrote:
> So if I understand this correctly:
>  
> This:
>  
>     if ($oWkS->{Cells}[$iR][0]) {
>       if ($oWkS->{Cells}[$iR][0]->Value != "") {
>         $myVar = ($oWkS->{Cells}[$iR][0]->Value)
>       }
>     }
>  
> Is the same as this:
>  
>     if (!$oWkS->{Cells}[$iR][0]) {}
>     elsif {$oWkS->{Cells}[$iR][0]->Value == "") {}
>     else {
>        $myVar = ($oWkS->{Cells}[$iR][0]->Value);
>     }

IMHO the 2nd is less readable.

> Which is shortcut(ed?) as this? :
>  
>     My $t = (!$oWkS->{Cells}[$iR][0];
>     $myVar = ((!$t) || ($t->Value != "") || $t->Value);

I think your unmatched ( and "My" will syntax error. Perhaps this?:

    my $t = $oWkS->{Cells}[$iR][0];
    $myVar = $t->Value if ($t && $t->Value);

?

j



More information about the Omaha-pm mailing list