in reply to check for existing value, else set to default

Is this what you meant? Taken literally, $a has a defined value, and the tertiary operator is unnecessary, so I presume you are looking for a default value kind of operation.

$a = 'text'; $b = $a || '';
Your third example is not reducible. At least, not by me.

Replies are listed 'Best First'.
Re: Re: check for existing value, else set to default
by waswas-fng (Curate) on Apr 26, 2004 at 06:03 UTC
    $a = 0; $a = $a || "1024"; if ($a == 1024) { print "ack $a = 1024 rm -rf ~\n"; }
    whoops.


    -Waswas