Greetings Monasteers, I am having a battle with object inheritance, specifically the problem that @ISA doesn't bequeath subs/functions only methods. I wanted to derive everything from Class::PObject so it would be nicely storable, but I think my mastery of OO Perl is wanting. Starting at the top,
#!/usr/bin/perl package myStorableBase; use Class::PObject; my @basedef = ["id", "name", "email", "phone"]; pobject # pobj is a persistent object { # can be saved and loaded columns => @basedef, # the entries driver => 'db_file', # to a db file normal unix datasource => "./data" # in this place }; sub thingysub { my $whatever = shift; return 1; } 1;
Which gives me a myStorable that I am happy with. In another file we have,
#!/usr/bin/perl package MyHuman; use myStorableBase; @ISA = ("myStorableBase"); # I am one of those cocky little monkeys with the hands and the fire a +nd the little green # pieces of paper. (aka 'Ugly Bag of mostly-water') # 1;
Human has a number of attributes and accessor/inspector methods that I've stripped out for clarity. However when I use myHuman I can's save the blighter, because it seems myHuman knows nothing about the subclass Class::PObject::DBM from which it gets its save(). I'm also confused becasue PObject doesn't seem to have a new constructor, it constructs a new instance using a subroutine 'pobject()' which I think is the source of all my woes. I need a PObject master, the docs don't say a lot about subclassing. Beat me with a cluebat! (or some more advanced Perl OO reading links) Cheers, Andy

In reply to Can't inherit subroutines - workaround? by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.