It sounds like you're taking the wrong approach. One of the selling points of inheritance is that your child classes behave just like the parent classes (at least interface-wise), and are therefore interchangeable (polymorphism).

If you're looking to simplify the interface to the base class, I wouldn't use inheritance at all. Make a new class as a wrapper around the more complicated class, sort of like the facade design pattern.

Example:

package ComplicatedClass; sub new { my $class = shift; return bless {}, $class; } sub method1 { print "This is method 1\n"; } sub method2 { print "This is method 2\n"; } .. sub method99 { print "This is method 99\n"; } sub method100 { print "This is method 100\n"; } package SimpleClass; sub new { my $class = shift; my $cc = new ComplicatedClass; return bless { cc => $cc }, $class; } sub method1 { my $self = shift; $self->{cc}->method1; } sub method42 { my $self = shift; $self->{cc}->method42; } sub method99 { my $self = shift; $self->{cc}->method99; } package main; my $obj = new SimpleClass; $obj->method1; $obj->method42; $obj->method99; $obj->method2; # Can't locate object method "method2" via package "Sim +pleClass"


In reply to Re: Inherit only few methods from a parent class by lostjimmy
in thread Inherit only few methods from a parent class 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.