Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Multi-Dimensional Arrays and Array References

by Fletch (Bishop)
on Nov 16, 2020 at 15:28 UTC ( [id://11123693]=note: print w/replies, xml ) Need Help??


in reply to Multi-Dimensional Arrays and Array References

You should (re-)read perlreftut and perllol while possibly having copies of Data::Dumper output of your samples' contents handy. That being said when you're referencing a single element of an array having a leading @ sigil is a good sign you're doing something wrong.

You're also probably confusing yourself trying to directly compare an array reference in the scalar $table against an actual array @table2. When you initialize my @table2 = [ [7, 8, 9], ... ] what you're actually doing is putting a reference to an anonymous array into the 0th (first) element (i.e. you're setting $table2[0] to point to an arrayref) so that's where your extra level of indexen comes in.

Edit: perldsc might also be useful for more examples. Also tweaked wording.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: Multi-Dimensional Arrays and Array References
by Leudwinus (Scribe) on Nov 16, 2020 at 18:37 UTC

    Hi Fletch,

    You are correct that I am very confused about

    • the difference between
    • how to work with, and
    • how to compare

    arrays and array references but the links to the Perl documentation pages you provided look quite useful. Thank you for directing me that way.

    I really love how perldoc allows you to browse those pages directly on the command line too!

    Gratias tibi ago
    Leudwinus

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found