
raxip
Novice
Jun 10, 2009, 7:42 PM
Post #1 of 3
(558 views)
|
|
Override certain package subs, but let other resolve normally
|
Can't Post
|
|
I've read a variety of man pages and perl books, but for some reason, I'm still having a difficult time understanding how to accomplish something -like- the following: package Foo; use Exporter qw( import ); our @EXPORT = qw( foo bar ); sub foo { print "Foo::foo()\n" } sub bar { print "Foo::bar()\n" } 1; --- package Foo::Bar; no warnings 'redefine'; use Exporter qw( import ); our @EXPORT_OK = qw( bar ); sub bar { print "Foo::Bar::bar()\n" } 1; --- #!/usr/bin/perl -w use strict; use Foo::Bar qw( bar ); bar(); foo(); --- The output: Foo::Bar::bar() Foo::foo() Essentially, I'm trying to override only a couple of the routines in someone else's module.. but leave the rest intact without having to necessarily create wrapper functions around every single sub that's inside the base module. Instead, let Perl's subroutine discovery mechanism find the one that has _not_ been overridden in the base module. What man pages should I consult to help understand more about that discovery process, and could someone lend a helpful hand? Thank you
|