in reply to why do I have to provide context to split result in a separate statement?

\(@arr = split / /, '') returns a list of references.

For example \( $a, $b, $c ) is actually ( \$a, \$b, \$c ) and you can't dereference that as an array.

What you could do is copy the list to an anonymous array:

print @{[@arr = split / /, '']}

Replies are listed 'Best First'.
Re^2: why do I have to provide context to split result in a separate statement?
by ikegami (Patriarch) on Sep 21, 2011 at 01:43 UTC
    Don't need to copy it into two arrays.
    print @{[ split / /, '' ]}
      Thank you very much!
        Only your code does that, not his.