in reply to Re^2: An Interesting Gotcha With use/require
in thread An Interesting Gotcha With use/require

As you can read in the followup to perrins comment, his comment is totally irrelevant, and only causes confusion. Your problem occurs because a subroutine gets defined twice. It has nothing to do with importing. See my example further down the thread - the one subroutine that's being redefined isn't exported.
  • Comment on Re^3: An Interesting Gotcha With use/require

Replies are listed 'Best First'.
Re^4: An Interesting Gotcha With use/require
by demerphq (Chancellor) on Feb 10, 2005 at 07:16 UTC

    Th thing I find interesting is that one useful solution to this problem that I can think of has everything to do with import. If the op had written:

    use File::BaseName qw(basename)

    then Perl could add a sanity check to its internal import() call to throw an error if import is missing but args have been provided as its almost certainly an error of some sort. Of course it doesnt right now, but it IMO it should.

    ---
    demerphq

      That only helps for modules that export anything. OO-modules typically export nothing, and hence, don't have an import module.
      But in order to know an import is missing, Perl first needs to compile the module. However, if Perl compiles the module, the "subroutine redefined" warnings are being thrown.

      You suggested check would have thrown another warning/error, but it wouldn't have eliminated the ones the OP was getting. I'm not sure that a warning "File::BaseName::import not found" would have been very helpful.