http://qs321.pair.com?node_id=780485


in reply to Re^4: fastcgi broke my Exports
in thread fastcgi did NOT break my Exports, issue now resolved

Thank you to perrin and to the Anonymous Monk, as well:

# perl -e 'use My::Module::Account qw(_GenerateAccountSummary); _Gener +ateAccountSummary();' Undefined subroutine &main::_GenerateAccountSummary called at -e line +1. # perl -e 'use My::Module::Account qw(_GenerateAccountSummary); My::Mo +dule::_GenerateAccountSummary();' Undefined subroutine &My::Module::_GenerateAccountSummary called at -e + line 1.
As for the advice from the anonymous monk, I was ready to dismiss the idea that I had typos in my code because this aspect of the code was working fine before the Etch-Lenny dist-upgrade and before installing fastcgi. However . . .

DEBUG: What the symbol table says about My::Module:: -- . . . 'log' => *My::Module::log, 'import' => *My::Module::import, . . .
Which is rather confusing because there is no ->import() method in either my base class, not in any of the custom modules it loads which I have written (at least if my grep pipe is to be believed). There is a ->new(), ->log(), ->_show_login_form(), ->_log_out() and a couple of others which are shown by Dumper(My::Module::).

Where might that ::import() be coming from if not from Exporter? And how is it I would figure that out?

So I rewrote my debug code like so:

{ $ENV{PATH} = "/bin"; foreach my $module (keys %INC){ my $result = `grep '^sub import' $INC{$module}`; if ($result){ print STDERR "The module: $module includes: \n$result \n"; } if($module =~ m/Account/){ print STDERR "The next module is: $module \n"; print STDERR `grep _GenerateAccountSummary $INC{$module}`; print STDERR "\n\n"; } } }
yielding the following output:

The module: CGI/Session.pm includes: sub import { The module: MIME/Types.pm includes: sub import_mime_types($) The module: SOAP/Lite/Utils.pm includes: sub import { The module: Exporter.pm includes: sub import { The module: subs.pm includes: sub import { The module: warnings/register.pm includes: sub import The next module is: My/Module/Account.pm our @EXPORT = qw( . . . _GenerateAccountSummary . . . ); our %EXPORT_TAGS = ( all => [qw( . . . _GenerateAccountSummary . . . +)] ); sub _GenerateAccountSummary { The module: bytes.pm includes: sub import { The module: vars.pm includes: sub import { The module: strict.pm includes: sub import { The module: AutoLoader.pm includes: sub import { The module: lib.pm includes: sub import { The module: re.pm includes: sub import { The module: Business/PayPal/API.pm includes: sub import { The module: warnings.pm includes: sub import The module: Devel/Trace.pm includes: sub import { The module: UNIVERSAL.pm includes: sub import { The module: /usr/local/share/perl/5.10.0/auto/Config/Simple/autosplit. +ix includes: sub import_names ; sub import_from ; The module: diagnostics.pm includes: sub import { The module: SOAP/Lite.pm includes: sub import { sub import { sub import { The module: version.pm includes: sub import { The module: Config/Simple.pm includes: sub import { sub import_names { sub import_from { The module: base.pm includes: sub import { The module: Config.pm includes: sub import { The module: integer.pm includes: sub import { The module: IO.pm includes: sub import { The module: FileHandle.pm includes: sub import { The module: constant.pm includes: sub import { The module: overload.pm includes: sub import { The module: CGI.pm includes: sub import { sub import_names {
So perhaps a third or more of the modules in %INC sport an ->import() method. Are they stomping on each other? And if so, how would I make them stop that and play nice?

-- Hugh

if( $lal && $lol ) { $life++; }

Replies are listed 'Best First'.
Re^6: fastcgi broke my Exports
by ikegami (Patriarch) on Jul 15, 2009 at 23:01 UTC
    # perl -e 'use My::Module::Account qw(_GenerateAccountSummary); _Gener +ateAccountSummary();' Undefined subroutine &main::_GenerateAccountSummary called at -e line +1.
    Three possibilities:
    1. &My::Module::Account::import doesn't exist and My::Module::Account doesn't inherit a method named import.

      Test:

      perl -wle'use My::Module::Account qw(_GenerateAccountSummary); print M +y::Module::Account->can("import") || "no"'
    2. The import does not create a sub named _GenerateAccountSummary in the caller's namespace in response to the call.

      Test:

      perl -wle'use My::Module::Account qw(_GenerateAccountSummary); print * +{$::{_GenerateAccountSummary}}{CODE} || "no"'
    3. _GenerateAccountSummary is successfully exported, but it has not been defined.

      Test:

      perl -wle'use My::Module::Account qw(_GenerateAccountSummary); print d +efined(&_GenerateAccountSummary) ? "yes" : "no"'

    The first to output "no" indicates the cause.