Update: Added output of sample code.

I apologize--I feel like I took your question too concretely, that I missed a modest mentoring tone in your first post, and that I provoked you to the defense of your module. You tossed out Module::Build as if it were germane when we were talking about neglected modules. That seemed red-herringish to me; did I miss a point?

If you fork privately, you have to maintain it in-house.

The wisdom I was trying to share:

Adrianh's solution, if usable, has the advantage of clarity.

For readability and lack of any downside of which I can think, my first choice for an outside patch would be to redefine the problem.

use Foo; package Foo; { no warnings "redefine"; sub foo { 'different foo' } } package resume_former_namespace; ...

I like the idea of aliasing away the problem but I can see how that could be very confusing to those year-later-and-you're-gone maintainers. It is not really possible to predict what semantics those folk will expect. Should foo or Foo::foo be overridden in below? I'd avoid that issue unless I need the flexibility.

Be well,
rir

#!/usr/bin/perl use warnings; use strict; use Foo; use Sub::Override; sub fixed_foo { "I'm overridden foo" } my $override = Sub::Override->new; $override->replace( 'Foo::foo' => \&fixed_foo ); # maybe 'foo' print "Foo::Ridden: ", Foo::foo(), $/; print "Foo::Ridden: ", Foo::bar, $/; print " ::Ridden: ", foo(), $/; $override->restore; print " ::Orig: ", foo(), $/;
File Foo.pm
package Foo; use Exporter; our @ISA = 'Exporter'; our @EXPORT = qw/ foo bar /; sub foo { "I'm foo" } sub bar { foo() . 'bar' } 1;
Output of above code overriding Foo::foo.
Foo::Ridden: I'm overridden foo Foo::Ridden: I'm overridden foobar ::Ridden: I'm foo ::Orig: I'm foo
Results of same code overriding foo.
Foo::Ridden: I'm foo Foo::Ridden: I'm foobar ::Ridden: I'm overridden foo ::Orig: I'm foo
~

In reply to Re^7: Upgrade-proofing overridden subroutines by rir
in thread Upgrade-proofing overridden subroutines by Ovid

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.