Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Undefined subroutine &abc::abcUtil::PERL_DEBUG

by navneet03 (Initiate)
on Aug 20, 2012 at 11:35 UTC ( #988435=perlquestion: print w/ replies, xml ) Need Help??
navneet03 has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl module : abcUtil.pm which has a subroutine check :
package abc::abcUtil; require "common.pl"; sub check { .. PERL_DEBUG(""); # PERL_DEBUG is in common.pl .. }
When I execute this , it works fine, But when i use this pm in another perl:
require "common.pl"; use abc::abcUtil; sub func { abc::abcUtil::check(); }
Here, if I call func(), I get this error : "Undefined subroutine &abc::abcUtil::PERL_DEBUG .." There are other direct occurrences of PERL_DEBUG in this perl file which are working fine. What might be wrong ? Thanks -------------- I updated the code in the 2nd file as follows:
#require "common.pl"; use abc::abcUtil; sub func { abc::abcUtil::check(); }
Basically removed the use of common.pl. Kept the abcUtil file as unchanged. Now it worked. But I can't keep it this way as have to use this common file. Is it some conflict due to the use of 'require "common.pl" ' in both the files?

Comment on Undefined subroutine &abc::abcUtil::PERL_DEBUG
Select or Download Code
Re: Undefined subroutine &abc::abcUtil::PERL_DEBUG
by moritz (Cardinal) on Aug 20, 2012 at 11:58 UTC

    You need to use Exporter and set it up so that &check is exported, and thus can e used in the script or modules that uses it.

    Update: MidLifeXis++ pointed out that it's a fully qualified call that goes wrong, so Exporter is likely not the solution.

    From the code you have shown I can't figure out what's wrong. But since the code you did show has so many errors (missing semicolon all over), I'd guess that the most likely cause is a mis-spelled package name. If that's not the case, please reduce your problem to a few lines in each file, and post the complete (reduced) code that shows your code.

      I updated the code in the 2nd file as follows:
      #require "common.pl"; use abc::abcUtil; sub func { abc::abcUtil::check(); }
      Basically removed the use of common.pl. Kept the abcUtil file as unchanged. Now it worked. But I can't keep it this way as have to use this common file. Is it some conflict due to the use of 'require "common.pl" ' in both the files?

        So what does common.pl do?

Re: Undefined subroutine &abc::abcUtil::PERL_DEBUG
by Anonymous Monk on Aug 20, 2012 at 12:24 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://988435]
Approved by Perlbotics
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-09-02 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (32 votes), past polls