Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: How to better represent a complex data structure.

by sundialsvc4 (Abbot)
on Jan 08, 2013 at 20:02 UTC ( #1012329=note: print w/replies, xml ) Need Help??

in reply to How to better represent a complex data structure.

Always bear in mind that Perl is a pragmatic language, built “out of necessity”   Lots of people (from “Larry Wall, himself” on forward) have faced the same problems that you did, and developed a pragmatic way to solve them.

In (this | your | their) case, the “magic pixie dust” is called references.   The apparent “complexity” of your situation in-fact arises from the fact that you need to insert “a complex data-structure” into one and only one place.   This requirement is very elegantly (and very completely ...) handled by the singular notion of “a reference,” which is:   “a single thing” (i.e. it can exist “in one place”) that can refer to (ommmm.....) anything-at-all.   (Furthermore, you can have any number of references to the selfsame thing ... so it can be in more than one place at the same time, if you so desire.)

The next key to this puzzle is ... that you can express this key notion without a bunch of extra steps.   In other words, without declaring a bunch of extra, otherwise-unnecessary variables.   Instead of “first” declaring @whatever and then later referring to \@whatever, you can simply describe what you really want, in one pragmatic step, and Perl will understand.

The Perl language is, after all, a human tool, that was originally conceived by someone who “had a job to ‘get done’,” and who devised the most-straightforward (to him... at the time ...) way, by which he could persuade a digital computer(!!) to do it.   (And hundreds if not thousands of other kindred souls, faced in their turn with the selfsame objective, have surely labored upon it since.)

Fact is... “Representing a complex data structure” is par for the course to every single one of us, from Larry Wall on down.   We’ve gotten very good at it.   ;-)

  • Comment on Re: How to better represent a complex data structure.

Replies are listed 'Best First'.
Re^2: How to better represent a complex data structure.
by eyepopslikeamosquito (Chancellor) on Jan 09, 2013 at 10:11 UTC

    “had a job to ‘get done’,”
    Awesome indeed. While quietly admiring your thoughtful placement of eleven pairs of “unnecessary quotes,” I was stunned by the inspired and original composition shown above: a pair of unnecessary single quotes embedded in a pair of unnecessary double quotes with a “chicago-manual-of-style” comma and some unnecessary typography thrown in for good measure! Well done.

Re^2: How to better represent a complex data structure.
by Amblikai (Scribe) on Jan 08, 2013 at 20:18 UTC

    Awesome reply! Thanks! I'll keep it in mind!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2018-05-26 18:19 GMT
Find Nodes?
    Voting Booth?