M
malgosia askanas
In perl5.6.1, this code:
$DEBUG = 1;
$DEBUG ? $prefix = 'foo' : $prefix = 'bar';
print $prefix
prints "foo", even though $DEBUG is set to 1. On the other hand, this code:
$DEBUG = 1;
$DEBUG ? print "foo\n" : print "bar\n";
prints "foo", as I would expect it to (and prints "bar" if $DEBUG is set to 0).
Why doesn't the first piece of code set $prefix to "bar"?
Many thanks in advance,
-malgosia
$DEBUG = 1;
$DEBUG ? $prefix = 'foo' : $prefix = 'bar';
print $prefix
prints "foo", even though $DEBUG is set to 1. On the other hand, this code:
$DEBUG = 1;
$DEBUG ? print "foo\n" : print "bar\n";
prints "foo", as I would expect it to (and prints "bar" if $DEBUG is set to 0).
Why doesn't the first piece of code set $prefix to "bar"?
Many thanks in advance,
-malgosia