Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I redefined the import method of a module
package M1; use parent qw(Exporter); our @EXPORT; sub func{print "Hello"} sub import{print "Imported";@EXPORT=qw(func)} 1;
And EXPORT is not working
perl -I. -le 'use M1;func()' Imported Undefined subroutine &main::func called at -e line 1.
But when I don't redefine import function, EXPORT works fine
package M1; use parent qw(Exporter); our @EXPORT; sub func{print "Hello"} #sub import{print "Imported";@EXPORT=qw(func)} 1;
How can I get both redefining import and EXPORT to work?perl -I. -le 'use M1;func()' Hello
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Redefined import method and EXPORT not working
by Corion (Patriarch) on Dec 22, 2014 at 08:11 UTC | |
by tobyink (Canon) on Dec 22, 2014 at 11:03 UTC | |
by Anonymous Monk on Jan 10, 2017 at 16:01 UTC | |
by Anonymous Monk on Dec 22, 2014 at 09:44 UTC | |
by Corion (Patriarch) on Dec 22, 2014 at 14:10 UTC |