
ternary conditional operator
JH> Why does this print no? I can't figure it out:
JH> ___________________________
JH> #!/usr/bin/perl
JH> $director = "else";
JH> $director =~ /else/ ? $redirto = "yes" : $redirto = "no";
your precedence is wrong. ?: binds tighter than =
regardless, you should do it this way:
$redirto = $director =~ /else/ ? "yes" : "no" ;
uri
--
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com