Vadim Konovalov <vkonovalov@lucent.com> writes: >Following: > >print 'foo'=~/(.*)/ && $1, 'bar'=~/(.*)/ && $1, "\n"; >print 'foo'=~/(.*)/ && "$1", 'bar'=~/(.*)/ && "$1", "\n"; > > >results in: > >barbar >foobar > >which was unexpected to me. It took me a little while to explain it as well. >While there may be found a way to explain such behaviour, it may result in >errors that are quite hard to find. The explanation of course is that both args to the print are evaluated before print itself is called. And in the non-stringified case both args are the (single) $1 variable. So it prints its value at time print is called twice. In the stringify case a copy is made which saves the value of $1 and time arg was evaluated. > >Is this a bug or not? It cannot be - changing either is bound to break something. >Is there a way to fix this? Not without breaking scripts which rely on the behaviour. > >Tried 5.6.0 and 5.005_02 on Win32 and Unix systems. > >Best wishes, ><!ENTITY Vadim REALLIFE "Vadim V.Konovalov, St.Petersburg, Russia"> >&Vadim; -- Nick Ing-Simmons <nik@tiuk.ti.com> Via, but not speaking for: Texas Instruments Ltd.Thread Previous | Thread Next