in reply to array and list return different things in scalar context
in thread How can I access the number of repititions in a regex?

a list in scalar context returns its last element

There's a somewhat detailed discussion of what's wrong with this idea starting about here. Here's one problem with it:

my @x = ( 6, 7, 8 ); my $last_element = (4, 5, @x)[-1]; my $as_scalar = (4, 5, @x); print "last element: $last_element\n"; print "as scalar: $as_scalar\n"; __END__ last element: 8 as scalar: 3

One might say that the scalar context is applied to the last element of the list expression (not the list itself). Note that scalar sub_that_returns_list() will apply the scalar context to everything in the sub's return list, but scalar ( 'literal', 'list', 'expression' ) puts 'literal' and 'list' in void context.