On Tue Nov 08 14:37:05 2011, b_jonas wrote: > This is a bug report for perl from ambrus@math.bme.hu, > generated with the help of perlbug 1.39 running under perl 5.14.2. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > > This command gives an unexpected result: > > $ perl -wE 'say scalar(($_x, $_y) = split "/", > "one/two/three/four/five");' > 3 > > One would naively think it should return 5, just like this command: > > $ perl -wE 'say scalar((@_x) = split "/", "one/two/three/four/five");' > 5 > But we also need to take into account the documentation for the 'scalar' function (perldoc -f scalar): ##### Because "scalar" is a unary operator, if you accidentally use a parenthesized list for the EXPR, this behaves as a scalar comma expression, evaluating all but the last element in void context and returning the final element evaluated in scalar context. This is seldom what you want. ##### My hunch is that in your first case above, the "final element evaluated in scalar context" would be '3', the number of elements in ( qw| three four five | ). Thank you very much. Jim KeenanThread Next