Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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!

Replies are listed 'Best First'.
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2016-12-11 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (168 votes). Check out past polls.