[Melbourne-pm] The || operator
thoughtstream at gmail.com
Mon Oct 31 15:23:32 PST 2005
Alfie John wrote:
> Looking through
> perlop, it says that this is the wrong way to use || and what would
> happen is:
> @a = scalar( (4,5,6) ) || (7,8,9);
> and thus @a would contain 3.
Not correct. A series of commas in scalar context doesn't create a list, but
rather remains a series of scalars, only the last of which is returned as the
resulting scalar value.
But, yes, it's one of those places where DWIM fails in Perl 5. If it's any
comfort, it works correctly in Perl 6 (and already in Pugs):
my @x = (4,5,7) || (1,2,3);
More information about the Melbourne-pm