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: Beginner:
cgi-lib.pl

 



DavidW
Deleted

Jul 4, 2000, 3:32 PM

Post #1 of 6 (928 views)
cgi-lib.pl Can't Post

I am a novice at perl and have been studying the scripts found here and on other sites. I frequently upload them to a test web-site to see them in action.

Some of the scripts call for a perl module named cgi-lib.pl. This module is not installed on the server of the site I use and the host says it can not be added.

Is this module common? Do I need to change hosts or is there a way to include a module that is not available on the server? Or would a different module that is installed serves the same function as cgi-lib.pl.

Thanks for any insight you can give me.


Kanji
User / Moderator

Jul 4, 2000, 4:08 PM

Post #2 of 6 (928 views)
Re: cgi-lib.pl [In reply to] Can't Post

cgi-lib.pl harks back to the days of perl 4, where modules didn't exist as such and people would save commonly used code in a library of sorts, and require that library as needed.

With perl 5 and the arrival of modules, Licoln Stein wrote CGI.pm, obsoleting cgi-lib.pl.

CGI.pm should be installed on any self-respecting web server that allows perl CGIs, and -- as luck would have it -- offers a backwards compatability mode.

Simply change ...

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

require "cgi-lib.pl";</pre><HR></BLOCKQUOTE>
... to ...
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

use CGI ':cgi-lib';</pre><HR></BLOCKQUOTE>


DavidW
Deleted

Jul 4, 2000, 8:29 PM

Post #3 of 6 (928 views)
Re: cgi-lib.pl [In reply to] Can't Post

Kanji

Thanks for the quick response. The server I am on does have cgi.pm installed.

It appears to me that the line of code searches for the path to the module since it actually reads:

require "$PATH_LIB/cgi-lib.pl";

would the modification you suggested traslate to:

use CGI '$PATH_LIB/:cgi-lib';

Neither that nor

use CGI ':cgi-lib';

seems to get the script to run.

Thanks again.



DavidW
Deleted

Jul 4, 2000, 10:53 PM

Post #4 of 6 (928 views)
Re: cgi-lib.pl [In reply to] Can't Post

I am a novice so the only error I get is the standard "Internal Server Error". Not much help to you, I know.

The particular script I was working with is probably more advanced than I should be attempting with the little knowledge I have at this point any way. However, the answer you provided concerning cgi/cgi-lib modules was very helpful for several other ones I want to work with.

Thanks again.


Kanji
User / Moderator

Jul 4, 2000, 11:46 PM

Post #5 of 6 (928 views)
Re: cgi-lib.pl [In reply to] Can't Post

Nope, it's just use CGI ':cgi-lib';.

As for getting your script to work, what is the error you get when you try to run it?


Kanji
User / Moderator

Jul 5, 2000, 12:01 PM

Post #6 of 6 (928 views)
Re: cgi-lib.pl [In reply to] Can't Post

If you've confirmed that use CGI ':cgi-lib'; does work by using it in other scripts (as it appears you have), then the problem is likely to be elsewhere within the script you're trying to run.

Anyway, you're right, INTERNAL SERVER ERROR isn't very helpful.

Can you run the script from a shell/DOS prompt to see what the error is?

Perhaps you could look in your web server's error log (or ask your local administrator to do so for you if they don't provide access) and see what that says.

Failing either of those two options, you can try debuging by using the following CGI ...

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

#!/usr/bin/perl


# Turn off buffering.
$|++;


# This is where you uploaded it on the
# server, NOT an URL.
my $broken_cgi = '/path/to/broken.cgi';


# Print HTTP headers and a marker (-----)
# so we're guaranteed output.
print "Content-Type: text/plain\n\n-----\n";


# Success status is inverted compared to
# traditional perl status (0 is success)
# so we 'AND die' instead of 'OR die'.
system( $broken_cgi )
and print "Couldn't run $broken_cgi: $!\n";</pre><HR></BLOCKQUOTE>

The first line shouldn't be a blank line and the first paragraph (followed by blank line) must contain a header like "Content-Type: .../..." or "Location: ...".

If you see neither of those, that's your problem.

 
 


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

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