Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

May I say, in all respect and courtesy and politeness, m'Lady, perhaps it is that you are “thinking too deeply into it.”   Many object-oriented language implementations impose many strictures upon how the language must work; upon how things must be done.   Perl does not.   (And there are sound engineering reasons for it, which perhaps do not immediately meet the eye.)   Therefore, if you are, perhaps unconsciously, trying to carry-over the concepts taken from those languages into this one, you’re going to wind up mightily confused for a while.

package is a declaration.   It simply notifies Perl about a name that is to be associated with all of the code that follows it, superseding any previous package-name or Perl’s default.   The significant thing here is that, when you refer to “a Perl object,” that object is always a package.   The subroutines in that package are the object’s methods; new is different as previously noted.   But the concept of packages, and the concept of objects, are only loosely related!

Start with perldoc perltoot and read that well-written documentation page very slowly and carefully.   Especially when it talks about new, which it does several times.   Consider, again very slowly and carefully, just what the bless function is actually doing, and why.   Of what we mean when we say that something is “a blessed reference,” and, if you like, exactly how the Perl language system represents that notion.   (It is literally a bit.)

Many object-oriented languages, as I said, are “object-oriented right down to the freckles on their skin.”   They simply can’t be approached in any other way.   And yet, here is Perl, and it implements the same concepts using just a small handful of concepts, artfully arranged, and never once does it say to you, “this is the Right Way ... you must do it This Way.”   Perl-heads are constantly saying, TMTOWTDI = There’s More Than One Way To Do It, and it takes a long time to grok the sheer genius(!) of what they are talking about.   You find yourself (or at least, I certainly did...) grasping around, saying, “where’s the rest of it?!”   But, then, you start to realize why this community uses the term, Monks.


In reply to Re: Why won't a hash in a hash work as a hash reference to create an object? by sundialsvc4
in thread Why won't a hash in a hash work as a hash reference to create an object? by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found