Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by jwkrahn (Monsignor)
on Sep 21, 2011 at 01:40 UTC ( #927045=note: print w/ replies, xml ) Need Help??


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 / /, '']}


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-09-16 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (10 votes), past polls