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

I just tested. it is not working. gives error "Undefined subroutine &main::InitializeLog called at .....".
I also tried a module named ToolSet for the same. but when i run it gives me error.
"Base class package "ToolSet" is empty. (Perhaps you need to 'use' the module which defines that package first.)".
  • Comment on Re^2: Want to create a common Perl module

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

    Could you show the exact code that you've written for abc.pm?  Which module is InitializeLog supposed to be imported from?

      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.

        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.