in reply to Re: Exporter. Correct way to override import?
in thread Exporter. Correct way to override import?

Get rid of archaic our @ISA = 'Exporter';. It doesn't make sense, and it hasn't been necessary since 5.8.3 (2004).

Correct. But it is still (as of version 5.72) the documented as a valid way to use Exporter. To make things worse, it is still the first example in the Synopsis, and it is in "Good Practices". See also Re^2: Advice on style, 7.5 years ago. There are no relevant changes in the documentation in the last 10 years / 9 versions: http://search.cpan.org/diff?from=Exporter-5.63&to=Exporter-5.72&w=1#lib/Exporter.pm

Alexander


Update: Fixed diff link and number of versions (was diff'ing between 5.63 and 5.70)

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^3: Exporter. Correct way to override import?
by ikegami (Patriarch) on May 06, 2018 at 18:44 UTC

    So what? Even if it is presented as an option, you should still not pick the version that makes no sense (unless you need compatibility with pre-5.8.3 builds of Perl).

      I had no time to answer earlier, but I fully agree with afoken.

      Unfortunately do the perldocs often reflect only an archaic Perl.

      It's no wonder if beginners become confused and frustrated.

      For instance we keep telling them to use strict and declare variables while a big part of the docs isn't strict at all.

      I consider this a real problem, because it's damaging the reputation of Perl.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Wikisyntax for the Monastery

        Unfortunately do the perldocs often reflect only an archaic Perl.

        Again, not so. Exporter includes

        package YourModule; use Exporter 'import'; # gives you Exporter's import() method directly @EXPORT_OK = qw(munge frobnicate); # symbols to export on request

        Well, I tried to do it without the ISA. But with the serious hack that I am trying to make as an experiment I can't get around just using export_to_level. export_to_level is not exported by Exporter by the way. The goto breaks the import method that I made because of its recursive nature and so I fully depend on export_to_level. I have not been able to figure out yet how to use the function without the ISA. Also Exporter->export_to_level( 1, @_ ) ; does not seem to work for me. Errors are of the kind: <Function Name> is not exported by the Exporter module.