[ABE.pm] ternary operator

Faber Fedor faber at linuxnj.com
Fri Jul 22 14:56:04 PDT 2005


I'm confoozled about the ternary operator.  I want to do this:

if($endYYYYMM) {
    $tempDate = $endYYYYMM."28";
}else{
    $tempDate = $YYYY.$MM."28";
}

IOW, if $endYYYYMM *exists* then $tempDate = $endYYYYMM."28" otherwise,
if $endYYYYMM *doesn't exist* (the user didn't pass it in on the command
line) set $tempdate to something different.

That works fine.

I thought I could be more succint by saying

$endYYYYMM ? $tempDate = $endYYYYMM."28" : $tempDate = $YYYY.$MM."28";

but that always executes the false statment, e.g. 
$tempDate = $YYYY.$MM."28".

I've run into this problem in a few other places, so I know it's not
related to the variables but rather my understanding of things.

What am I missing?


-- 
 
Regards,
 
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701

http://www.linuxnj.com





More information about the ABE-pm mailing list