CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Undefined subroutine error


New User

Oct 3, 2012, 11:48 AM

Post #1 of 3 (2086 views)
Undefined subroutine error Can't Post

I have written a perl script that is supposed to call a subroutine (PrintPageHeader) in another script ( (The PrintPageHeader subroutine prints the html code for the header portion of a webpage that is used in several scripts). My calling perl script uses require '/fullpathtoscript/'. Later the script calls the subroutine with its parameters PrintPageHeader($ClientName, $ClientLogo);

The problem that I am having is that sometimes I am getting the error message "Undefined subroutine &ModPerl::ROOT::ModPerl::Registry::website_thrasherandheckman_2dsecure_cgi_2dbin_Caseshow_2epl::PrintPageHeader called at /website/thrasherandheckman-secure/cgi-bin/ line 45. " I cannot understand how this error is happening. It is happening intermittently but regularly. Sometimes, the error will occur when the page initially displays properly and I hit refresh.

Any ideas what might cause this problem?


Oct 3, 2012, 12:57 PM

Post #2 of 3 (2084 views)
Re: [PerlyTrey] Undefined subroutine error [In reply to] Can't Post

use the module lib and this will add a directory to the @INC where perl stores directories to look threw for modules or scripts. it will need to be in all scripts the require file.

The error is comming from it not finding the and useing lib module should fix that.

use lib qw(/usr/bin/dir/to/base/ c:/dir/to/base/); 
use strict;
use warnings;

#require the script



Veteran / Moderator

Oct 3, 2012, 4:59 PM

Post #3 of 3 (2075 views)
Re: [PerlyTrey] Undefined subroutine error [In reply to] Can't Post

Another improvement would be to convert the script into a true module which exports its subs.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives