Of course! It appears 'import' is a special case, presumably because many modules don't define it, yet it's always called by 'use'.
C:\>perl -w -MStrict -le "Strict->import"
C:\>perl -w -MStrict -le "Strict->foo"
Can't locate object method "foo" via package "Strict"
(perhaps you forgot to load "Strict"?) at -e line 1.
So how was the OP getting a subroutine redefined error in the first place if the import wasn't getting called?
FooBar.pm
package FooBar;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(foo);
sub foo {
print "foo called\n";
}
1;
test1.pl
#!/usr/bin/perl
use strict;
use warnings;
use FooBar qw(foo);
foo();
> foo called
test2.pl
#!/usr/bin/perl
use strict;
use warnings;
use foobar qw(foo);
foo();
> Undefined subroutine &main::foo called at foo.pl line 7.
This suggests to me that the File::Basename->import would have worked,
but the File::BaseName->import would not have worked, thus redefining nothing. |