Greetings,

I am posting what follows by toma's request (very nearly yanked from somewhere in the panther bbok, so I cannot really claim authorship :) ).

package My::Tmain; sub new { #somewhere... $self_>{_TMAIN_}=Win32::OLE->new('mynifty.application') or barf('badly'); #... bless $pkg $self; } #override something sub foo { my $self=shift; my $res = $self->{_TMAIN_}->foo(@_); munge($res); } #elsewhere sub AUTOLOAD { my($self,@args)=(@_); my($cmd); ($cmd=$AUTOLOAD)=~s/.*:://; return if $cmd eq 'DESTROY'; # should not even be called { #this may be bititing toma... no strict 'refs'; # this does the delegation hokey dokey $self->{_TMAIN_}->$cmd(@args); } } #in another file use My::Tmain; my $t= My::Tmain->new(); $t->foo(); # calls the overridden method $t->bar(); # autoloaded
Note that no strict refs is required to make the ->$cmd( ) bit work. I see nothing that should stop this from working with Bit::Vector... but then again, I would not have anticipated the impossibility to inherit. Manual overriding is obviously possible but much more tedious and error prone than this


Cheers,
alf


You can't have everything: where would you put it?

In reply to Re: How can I inherit from Bit::Vector? by alien_life_form
in thread How can I inherit from Bit::Vector? by toma

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.