On Feb 4, Brett W. McCoy said:

>On Mon, 4 Feb 2002, david wright wrote:
>
>> i can't use the ternary operator like this? (damn waste if not) thanks.
>>
>> foreach $dup (@array){
>>     (-d  $dup) ? print "yes: $dup  \n": print "no:  $dup \n";
>> )
>
>Yes, that is an incorrect way to use the ?: operator -- the operataor is
>handed an expression that yields a boolean value, and it returns a value
>based on what that boolean value is:

That's not to say his use is incorrect.

  EXPR ? EXPR : EXPR

His code fits...

  (-d $dup) ? (print "yes: $dup\n") : (print "no:  $dup\n")

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to