Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chaoticset (2105)

chaoticset
  (email not shown publicly)
http://chaoticset.perlmonk.org/
AOL IM: chaoticset23 (Add Buddy, Send Message)
Yahoo! ID: illuminatus_foil (Add User, Send Message)

JAPH. (That's right -- I'm not Really Inexperienced any more.)

I'm not just here, I'm here [perlmonks.org], and here [javajunkies.org] too, I ramble randomly in my philosophical blog [blogspot.com] and my other blog [blogspot.com]. Soon I'll come in a convenient six-pack.

Journal of chaoticset (2105)

Sunday February 10, 2002
11:18 AM

OOPs

[ #2752 ]
Well, I get the basics; I get basic inheritance, basic object creation, and methods being subroutines.

The thing I'm working on today is the data side of this issue. I'm still very, very fuzzy on how data ends up in an object, but I think I'm on the verge. A few more examples, a little more footling about, and then I'll download something small and OO and try to dissect it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Data is in an object usually by saving it in the object variable. For example, most people most often use hashrefs as object data structures:

        sub new {
            my $class = shift;
            return bless {}, $class;
        }

    Some people will just allow data access via this hash, directly:

        sub new {
            my $class = shift;
            return bless {blargh => 'data'}, $class;
        }

    • I get everything except {_data}. I've never, never seen that before to the best of my recollection. Looking up {_data} came up blank in _Bookshelf_.

      So that I can look it up, what's that called?

      --

      ------------------------------
      You are what you think.
      • _foo is a convention for "this is private, don't touch it." So by putting your data in the object hashref under the _data key, you are telling people who use the object and inspect its contents that they shouldn't touch that data directly, but access it via the published API.