wfsp has asked for the wisdom of the Perl Monks concerning the following question:

Sorry about this. I have a simple module...
#!/usr/bin/perl -T package CWI::Message; use warnings; use strict; use CGI::Carp qw(fatalsToBrowser); use Exporter; use vars qw( $VERSION @ISA @EXPORT ); $VERSION = 1.00; @ISA = qw( Exporter ); @EXPORT = qw( &get_msg ); sub get_msg{ return 'message from module' } 1;
And a script...
#!/usr/bin/perl use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); my $path; BEGIN { $path = $ENV{ DOCUMENT_ROOT } . '/z_cwi_cgi' } use lib $path; use CWI::Message; # works as expected my $msg = ''; # 'Undefined subroutine &main::get_msg' #$msg = get_msg(); print <<HTML; Content-type: text/html <html><head><title>Module test</title></head><body> <p>test_mod.cgi</p> <p>$path</p> <p>$msg</p> <p>back in test_mod.cgi</p> </body></html> HTML
I haven't use taint here, I think it kicks up over the $ENV variable. When I hard code the path the result is the same.
Again, apologies and again, thanks in advance. wfsp
update:
remote is solaris, 5.8 and local is winXP, 5.8
It runs ok on my local m/c. On the remote m/c it returns: 'Undefined subroutine &main::get_msg'

Replies are listed 'Best First'.
Re: Simple module crashes on remote server
by tinita (Parson) on Jul 13, 2004 at 10:57 UTC
    that is either a bug, or you're not using the module code you've shown above.
    try to make sure you're using exactly that module (by adding a print into the module body).
    or do this:
    print join "\n", @INC; print "$INC{'CWI/Message.pm'}\n";

    in the script, and tell us the full path of CWI/Message.pm and if there are any other CWI/Message.pm files lying around your file system.
    another question, what happens if you explicutly use use CWI::Message qw(get_msg);?
      "or you're not using the module code you've shown above"
      Spot on! I had tried to replicate the structure on my local m/c and not tried hard enough. An older module was being ftped. You're debug tips revealed it straight away.
      Many thanks,
      wfsp (feeling very foolish)
      Now, those head shaped dents in the wall...
Re: Simple module crashes on remote server
by Chady (Priest) on Jul 13, 2004 at 10:18 UTC
    @EXPORT = qw( &get_msg );
    should be
    @EXPORT = qw( get_msg );
    (forget that, doesn't mean anything)

    Update: What exactly is the problem you're having? try adding -w to the script to actually see the errors if any.


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
      Hi,
      Undefined subroutine &main::get_msg
      wfsp