The
scalar() function does not return the size of a list. It enforces scalar context upon its argument. Some functions behave different in scalar context than in list context. Arrays return their length in scalar context.
Lists, however, don't exist in scalar context. But the comma operator does exist in scalar context; it evaluates its operands, and then returns the one on the right.
print scalar(1,2,3,4); # 4
print scalar(2,3,4); # 4
print scalar(4,3,2,1); # 1
japhy --
Perl and Regex Hacker