in reply to Re^3: When doesn't the flip-flop operator work in all scalar contexts?
in thread Why doesn't the flip-flop operator work in all scalar contexts?
#### prints nothing. Why??? It doesn't test against $. and it doesn't just test the value $x
$x is not a constant expression, so $. doesn't come into play. You're right about that bit.
But you're wrong about it not just testing $x. The reason it never prints anything is that it flips again as soon as it flops since $x is always true.
my $x=1; for(1,2,3,4,5) { next if (printf("flip at %s? %s\n",$_,$x?'yes':'no'),$x) .. (printf("flop at %s? %s\n",$_,$x?'yes':'no'),$x); print "$_\n"; }
flip at 1? yes flop at 1? yes flip at 2? yes flop at 2? yes flip at 3? yes flop at 3? yes flip at 4? yes flop at 4? yes flip at 5? yes flop at 5? yes
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: When doesn't the flip-flop operator work in all scalar contexts?
by jethro (Monsignor) on Oct 02, 2008 at 20:07 UTC | |
by ikegami (Patriarch) on Oct 02, 2008 at 20:56 UTC | |
by jethro (Monsignor) on Oct 02, 2008 at 21:12 UTC |