http://qs1969.pair.com?node_id=586664

Melly has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monkees,

Why does the following code print 10 bars for the first section, yet behaves as I expected for the second?

#Huh? 10 bars, WTF? for(1..10){ $_>5 ? $x='foo' : $x='bar'; print "$_:$x\n"; } # That's better - 5 foos and 5 bars for(1..10){ $x=($_>5 ? 'foo' : 'bar'); print "$_:$x\n"; }
Tom Melly, tom@tomandlu.co.uk