in reply to Re^3: An Interesting Gotcha With use/require
in thread An Interesting Gotcha With use/require
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
> foo called#!/usr/bin/perl use strict; use warnings; use FooBar qw(foo); foo();
test2.pl
> Undefined subroutine &main::foo called at foo.pl line 7.#!/usr/bin/perl use strict; use warnings; use foobar qw(foo); foo();
This suggests to me that the File::Basename->import would have worked, but the File::BaseName->import would not have worked, thus redefining nothing.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: An Interesting Gotcha With use/require
by bart (Canon) on Feb 10, 2005 at 14:15 UTC |