Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^3: -> Is Optional ?

by Athanasius (Canon)
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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2015-12-01 03:11 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (792 votes), past polls