Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I think I typed an accidental character or *something* in one of my modules or files...

I get multiple subroutine "redefined" errors, but I searched ALL code and know it is defined only once...If I comment the fn out, the warning goes away.

Is there a way to see how the interpreter sees the code? I tried perl -P, but I am on Win32 and it wanted 'sed'...

(perl -c went OK) Unfortunately there is nothing I can post, but I have looked through the files many times and can't see my mistake.

thanks !!!

Replies are listed 'Best First'.
Re: see perl output before run
by seattlejohn (Deacon) on Mar 08, 2002 at 02:46 UTC
    You could try perl -MO=Deparse script.pl if you want to see how the interpreter sees the code.

    You're sure you haven't redefined a subroutine that might exist in modules you're using?

      I tried it and got: Can't call method "PADLIST" on an undefined value at C:/Dev/Perl/lib/B/Deparse.p m line 1039. CHECK failed--call queue aborted. I must have done something really good !
        That's just a bug in the old version of B::Deparse. Perl 5.8 will be available before too long and fix the problem, but until then you're out of luck.
Re: see perl output before run
by chromatic (Archbishop) on Mar 08, 2002 at 04:28 UTC
    If you're importing a function from another package with the same name as a function in the existing package, you may also see this error:
    $ perl -w use strict; sub param {} use CGI qw( :standard ); Subroutine param redefined at /usr/lib/perl5/5.10.1/CGI.pm line 235.
      Hi,

      I fixed it, but am not happy with my solution...I am still not *thinking* Perl !

      This is an example of the mess I created. The problem probably stems from the fact that I have a global structure that all modules reference and so my packages cross-call each other all of the time. The way I got out of it is to allow the main() to have all of the "use module" definitions and then in each package, I preface each function call with the name of the package. If I did a "use" in the package and it was also "used" in main() I would often get conflicts...

      package::A fn1() fn2(PackageB::FnA) fn3() package::B fnA(packageA::fn1) fnB() fnC()
      I am trying to isolate the variables with each individual package and provide method calls to set/get...maybe I just need to keep at it and then it will *feel* better to me...or maybe I am not using things right...