Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Getting out an array within an array

by sundialsvc4 (Abbot)
on Oct 01, 2012 at 20:03 UTC ( #996732=note: print w/replies, xml ) Need Help??

in reply to Getting out an array within an array

Hello, Oskar!   Maybe the following concept will help to crystalize your thoughts and make the possible approaches clear ...

Perl, itself, only has a small handful of very-simple data structures ... a one-dimensional “list” or “array,” ... a “hash” ... a “scalar” ... but(!) ... within all of that ... it also has the all-important concept of a reference.

“A reference” is “a single thing,” just like (say...) an integer or a string, in the sense that “it occupies only one slot in” a scalar or an array or a hash.   But it could refer to “anything(!!).”   (So, if you have ever wished to be in two places at one time, “references” are darned-close to Willy Wonka’s “Golden Ticket.”)

When you say, “an array within an array,” well ... no such thing exists.   What does exist is something much simpler and much more powerful.   The array-element in question consists of a reference to ... another (in this case) array.

Here is the “cognitive jump” that you have to jump:   on the one hand, “a reference is” a single thing.   But on the other hand, that reference can refer to absolutely anything at all.   A scalar ... an entire hash ... an entire list ... an entire array ... even itself.

Please wait patiently until “the little light blinks on,” because when it finally does, it will be well worth it.   You can in facct build data-structures of arbitrary complexity through judicious application of this “small handful of primitives” that the Perl language gives you.   “References” are the “real Golden Ticket” that allows you to pair anything with anything-else.

  • Comment on Re: Getting out an array within an array

Replies are listed 'Best First'.
Re^2: Getting out an array within an array
by Anonymous Monk on Oct 02, 2012 at 06:18 UTC

    Your "post" looks rather "funny" to me. May I recommend :-)

      Your "post" looks rather "funny" to me. May I recommend :-)
      That is just “the tip of the iceberg®”   ...  you “forgot” about ... unnecessary underlines, italics ... ellipses ...   boldface, (parentheses)-and-hyphens and exclamation marks (!!),   non-breaking-spaces ...   ™,   ®,   and other “symbols,” stylistic “devices,” flowery-analogies, and ...   “old bull-shitter wisdoms™”   (“Schweet!”)   ;-)

Re^2: Getting out an array within an array
by sokatron (Initiate) on Oct 02, 2012 at 06:37 UTC
    Thanks! Thats what I get for "inventing" my own words, no wonder I scored so few google hits if it is not even a feature called that. I think I get how it will serve as a reference. Now that I know the concept I will try to understand how I can use it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://996732]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2018-03-21 13:09 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (267 votes). Check out past polls.