$_ eq 's' ? $OPER='s' : $OPER='c';
That's a priority issue. Try:
$_ eq 's' ? ($OPER='s') : ($OPER='c');However, your code has a worse problem: mo strict nor warnings. As a consequence, your usage of lc is useless without you noticing it:
print "Field 1 & 2 Separate or Combined? "; chomp($_=<STDIN>); lc($_); $_ eq 's' ? $OPER='s' : $OPER='c'; print "OPER $OPER\n"; __END__ Field 1 & 2 Separate or Combined? S OPER c
Try this fixed version:
use strict; use warnings; print "Field 1 & 2 Separate or Combined? "; chomp ($_ = <STDIN>); my $OPER = lc eq 's' ? 's' : 'c'; print "OPER $OPER\n";
--
David Serrano
In reply to Re: ternary operator
by Hue-Bond
in thread ternary operator
by pglenski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |