Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: difference between @, $

by sumeetgrover (Scribe)
on Dec 07, 2011 at 16:02 UTC ( #942276=note: print w/ replies, xml ) Need Help??


in reply to difference between @, $

I like choroba's answer, it's exactly the way it works. On a theoretical note:
* List/Array assignment: @list=('el1','el2','el3');
(Note, the parenthesis indicate that a regular array initialisation is being carried out.)
* Array Reference Assignment: $aref=['el1','el2','el3']
(Note, the scalar variable $aref is being assigned a reference to a list, enclosed in square brackets).

Enjoy!


Comment on Re: difference between @, $
Select or Download Code
Re^2: difference between @, $
by JavaFan (Canon) on Dec 07, 2011 at 17:30 UTC
    Note, the parenthesis indicate that a regular array initialisation is being carried out.
    Eh, no. The list assignment actually stems from the LHS of the assignment being an array, not from the RHS having parens. The parens are needed because the comma has a lower precedence than the assignment operator.
    $a = (1, 2); # Parens, but scalar assignment @a = 1; # No parens, but list assignment

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-07-24 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (157 votes), past polls