in reply to Tutorial::What is true and false?

print (defined $a) ? "Defined\n" : "Undefined\n";
is being parsed as:
(print defined $a) ? "Defined\n" : "Undefined\n";
You need to get rid of those parens, or add an extra layer to have print consider the entire rest of the line to be its arguments, like:
print ((defined $a) ? "Defined\n" : "Undefined\n");

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Tutorial::What is true and false?
by japhy (Canon) on May 27, 2001 at 19:47 UTC
    Or, like I said in the other place this was posted, put the parens in a more normal place: around the arguments to defined:
    print defined($a) ? "defined\n" : "undefined\n";


    japhy -- Perl and Regex Hacker
Re: Re: Tutorial::What is true and false?
by tachyon (Chancellor) on May 27, 2001 at 20:42 UTC

    Yes Randal, I know that idiom is broken -> as stated, you may also note that I already use your suggestion in the 5 different working idioms presented. :-)

    Thanks for that japhy, totally elegant. Either you were obtuse or I was thick last post!

    tachyon