Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: -> Is Optional ?

by Athanasius (Monsignor)
on Dec 29, 2012 at 16:34 UTC ( #1010827=note: print w/ replies, xml ) Need Help??


in reply to Re^2: -> Is Optional ?
in thread -> Is Optional ?

The line

my @a = [ 1, 4, 9, 16 ]; # squares

creates an anonymous array with 4 elements, and assigns a reference to this anonymous array — i.e., a single, scalar value — to be the first (and only) element of the named array @a.

I suspect that parentheses were intended rather than square brackets:

my @a = ( 1, 4, 9, 16 ); # squares my @b = ( 1, 8, 27, 64 ); # cubes my @c = ( \@a, \@b ); # two arrays

and then the rest of the original code behaves as intended.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re^3: -> Is Optional ?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-07-31 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls