perldoc says “a list assignment in scalar context returns the number of elements on the right-hand side of the list assignment” but when I try this code:
perl -e '$_="aaaaa";print $v=(()=split //)'
The output is 1 which makes me confused. (The answer I expect is 5.)
Can anybody explain this?
According to
splitdocumentation:Since you specify empty list,
splitonly returns 1 result and this number of results is exactly what ends in your variable.