I dropped in here because I saw "Sybase", but:

You should probably use @ISA and SUPER when you want to override methods from existing modules. Something like:

package My::Db; use Sybase::DBlib; our @ISA=qw(Sybase::DBlib); # new() is only needed if you need to do additional # stuff - otherwise Sybase::DBlib's new() is called # automatically sub new { my $package = shift; my $dbh = $package::SUPER->new(@_); # do something with $dbh here .... return $dbh; } # Override dbnextrow() to allow ad-hoc processing sub dbnextrow { my $self = shift; # Call the real dbnextrow() my @row = $self::SUPER->dbnextrow(@_); # and now do some magic with @row before # returning it... .... return @row; }
If you do it this way the whole system becomes extensible - you'll note that I never mention Sybase::DBlib in the package itself - only in the @ISA - and this lets perl decide at run-time what methods to call based on the inheritance tree.

Michael


In reply to Re^2: Altering Package Subs and Running In To Problems by mpeppler
in thread Altering Package Subs and Running In To Problems by Bovine

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.