use strict; use warnings; my $logical = 1; my ($a,$b); $a = $logical ? 2 : 'a'; $b = $logical ? 'b' : 'x'; print "a is $a\n"; print "b is $b\n"; $logical = 0; print "\$logical is now false\n"; $a = $logical ? 2 : 'a'; $b = $logical ? 'b' : 'x'; print "a is $a\n"; print "b is $b\n"; OUTPUT: a is 2 b is b $logical is now false a is a b is x
In reply to Re: ternary conditional help
by BillKSmith
in thread ternary conditional help
by opaltoot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |