<abigail@foad.org> writes: >On Mon, Mar 12, 2001 at 12:30:43PM +0000, David Mitchell wrote: >> Konovalov, Vadim" <vkonovalov@lucent.com> wrote: >> >> > print 'foo'=~/(.*)/ && $1, 'bar'=~/(.*)/ && $1, "\n"; >> > print 'foo'=~/(.*)/ && "$1", 'bar'=~/(.*)/ && "$1", "\n"; >Yes, for calling functions. And that's documented. But perlop says: > > The `||' and `&&' operators differ from C's in that, rather than > returning 0 or 1, they return the last value evaluated. > >It clearly states *value*. Not address. Not alias. Value. > >And before you say it's because print is being called and that's a function, >you are wrong. That's irrelevant; it's about what && returns. > > $a = (($foo = 2) && $foo) + (($foo = 3) && $foo); > print $a; > >prints 6, not 5 as you would expect if && returns a value. The value in this case is $1 and that variable is then changed. The 'fail' is just the same as the (expected to me) behaviour of: perl -e 'print STDOUT ($a = 4),($a = 5);' -- Nick Ing-SimmonsThread Previous | Thread Next