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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Undefined subroutine... ?

 



mike robb
Deleted

Sep 14, 2000, 6:13 PM

Post #1 of 3 (1109 views)
Undefined subroutine... ? Can't Post

I have been porting working perl scripts from one server to another - both running apache on linux. I ziped up the files ported over and unziped (-a option!) on the new server.

I am now getting a server log error (in the apache error log file)

Undefined subroutine &SmallPig::get_config called at /home/q8/public_html/cgi-bi
n/forum/sporum/cindex.cgi line 12.
[Thu Sep 14 22:05:04 2000] [error] [client 209.245.237.141] Premature end of scr
ipt headers: /home/q8/public_html/cgi-bin/forum/sporum/cindex.cgi


The subroutine SmallPig::get_config exists in the parent directory and I have the code (verified working correctly) that has inserted the correct path (INC):

Undefined subroutine &SmallPig::get_config called at /home/q8/public_html/cgi-bi
n/forum/sporum/cindex.cgi line 12.
[Thu Sep 14 22:05:04 2000] [error] [client 209.245.237.141] Premature end of scr
ipt headers: /home/q8/public_html/cgi-bin/forum/sporum/cindex.cgi

The above error poped out if I put a "use SmallPig" prior to the call to the subroutine.

it seems obvoius to me that there is another problem that is causing me to need the "use" statement on my new server.

Any idea what would change to cause me to need to use the "use" statement?

[if i need to post more information please let me know and i will Smile]

cheers.



fashimpaur
User / Moderator

Sep 15, 2000, 4:21 AM

Post #2 of 3 (1110 views)
Re: Undefined subroutine... ? [In reply to] Can't Post

Mike,

Here is what it looks like to me. Forgive me if I don't get it right.

First off, you have the module SmallPig. You
are calling the subroutine get_config and get the error that is undefined unless you say 'use SmallPig'.

Well, SmallPig is a module and you must, in your script either 'use' or 'require' it.
Since it is not in the standard Perl Module Library (I don't think I've seen it on CPAN but then again there are hundreds of modules on CPAN), I would think there should be included some reference to 'use' or 'require'
it or it's directory should be in the 'lib' path.

If you were using the Perl Builder IDE and had it open as a module when you tested the script that calls it, Perl Builder will not give you that error. It will however happen on a real server.

Things to try:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use lib qw( /SmallPig/Directory );
</pre><HR></BLOCKQUOTE>
or
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use SmallPig;
</pre><HR></BLOCKQUOTE>
or
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


require SmallPig;
</pre><HR></BLOCKQUOTE>

Also, could it be the SmallPig sit's in the cgi-bin directory and you are calling it from a script to subdirectories deep?

I one of these is the reason, but would need
more detail to determine exact cause.

HTH,

Dennis


mike robb
Deleted

Sep 15, 2000, 1:22 PM

Post #3 of 3 (1109 views)
Re: Undefined subroutine... ? [In reply to] Can't Post

the module SmallPig.pm is part of a forum system (open source project) - http://www.js-examples.com/sporum if you are interested in exactly what the bigger picture is all about.

this module is one of many many modules that comprise the forum.

I have a working setup of this forum on one server and ziped up the entire file structure and ported the zip file to the new server. on this new server i unzipped the files (-a option to preserve the ascii representation of the perl files!)

so all the files are exactly the same as they are on the working system.

the next step was to make modifications to the configuration files that specify paths to files and the like.

after this step i was trying to run the system and the file in question is run via the web browser (or telnet as it does not matter to get the error) and it can not find the module SmallPig.pm

On the current working server forum system the file (exactly as it is with no "use" or "require" that i'm aware of) works fine, but the new server file does not.

I have included the file below for completeness.

the INC path does get updated correct - as i have put print statements in to see what is going on)

#!/usr/bin/perl

my ($fbconfig, $config);
BEGIN {
use FVars;
$fbconfig = FVars::get_fconfig();
unshift(@INC, $fbconfig->{sp_cgi});
}

$config = SmallPig::get_config();

use FDB;
use FCGI;

use strict;

sub main{
# print "Content-type: text/html\n\n";

my $spdb = FDB->new($config);

my $spcgi = FCGI->new($spdb, "cindex", $config);
$spcgi->set_state_for_client();

my $STATE = $spcgi->{'STATE'};
my $op = $STATE->{'op'};

# --- create a templa1te object
my $template;
require Templates::CIndex;

$template = Templates::CIndex->new($spcgi, $spdb);

# --- print the http header
$template->print_http_header();
$template->print_template();
}

main();
---end of file---

 
 


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

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