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:
Here is a one liner that accomplishes what you want:
$ perl -e '$ans = (-d "/usr/bin") ? "yes\n" : "no\n"; print $ans'
yes
-- Brett
http://www.chapelperilous.net/
------------------------------------------------------------------------
"The Lord gave us farmers two strong hands so we could grab as much as
we could with both of them."
-- Joseph Heller, "Catch-22"
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]