Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: -> Is Optional ?

by Athanasius (Abbot)
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 musing on the Monastery: (15)
As of 2015-07-02 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (40 votes), past polls