in reply to Re^3: Want to create a common Perl module
in thread Want to create a common Perl module

package abc;
use strict;
use myCustom::SysLogLoader;
use myCustom::amodule;
use myCustom:firstmod;
use File::Path 'mkpath'; # for mkdir
#use warnings;
use integer;
use File::Basename;
use File::Copy; # for move
use IO::Zlib; # to read gzip input files use IO::File; # to read non gzip input files use Text::Trim; use Data::Types qw(is_int is_string);
use Shell qw (cat);
use Sys::Hostname;
use Time::Local;
#our @ISA = qw(Exporter);
sub import {
my $caller =caller();
strict->import();
warning->import();
MyCustom ::amodule ->import();
myCustom:: firstmod->import();
myCustom ::SysLogLoader->import();

now i am using this package abc into my other myplscript.pl file. then it gives me this error.
  • Comment on Re^4: Want to create a common Perl module

Replies are listed 'Best First'.
Re^5: Want to create a common Perl module
by almut (Canon) on Jun 28, 2010 at 15:31 UTC

    As I mentioned, when myCustom::SysLogLoader uses Exporter, you have to write

    { eval "package $caller; myCustom::SysLogLoader->import();" }

    Likewise for the other modules.  Simply writing

    myCustom::SysLogLoader->import();

    won't work in this case, because Exporter will then export the functions/symbols into the package abc, not the package in which you say use abc;

    ___

    P.S.: please use code tags (<c>...</c>) for code, and also please cut-n-paste it — there are several typos in what you posted.