prowler has asked for the wisdom of the Perl Monks concerning the following question:
I have some modules that use each other and am getting subroutine redefined warnings when compilation is done (using perl -c) on one of the modules.
Some sample code that does what I mean is:
Foo.pm:Bar.pm#!/usr/bin/perl use warnings; use strict; use lib '/tmp/'; package Foo; use Bar; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = {}; return $self; } sub get_bar { return Bar->new(); } 1;
#!/usr/bin/perl use warnings; use strict; use lib '/tmp/'; package Bar; use Foo; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = {}; return $self; } sub get_foo { return Foo->new(); } 1;
Subroutine new redefined at Foo.pm line 13. Subroutine get_bar redefined at Foo.pm line 22. Foo.pm syntax OK
This is mainly irritating as it adds to the list of errors and warnings that appear in the Problems tab of Eclipse when editing.
I know that I can disable warning check for those problems (which I don't want to do as it may hide a real problem), or I can remove each module's use of the other and just ensure that the scripts that call these modules use both of them, but it seems to me that this sort of design should be valid.
Does anyone have any ideas of how to cross use modules without having subroutine redefinition issues?
Thanks,
Prowler
- Spelling is a demanding task that requies you full attention.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Recursive use causes subroutine redefinition
by ysth (Canon) on Sep 08, 2004 at 08:49 UTC | |
by prowler (Friar) on Sep 08, 2004 at 14:38 UTC | |
|
Re: Recursive use causes subroutine redefinition
by tachyon (Chancellor) on Sep 08, 2004 at 07:49 UTC | |
by prowler (Friar) on Sep 08, 2004 at 08:09 UTC |