heezy has asked for the wisdom of the Perl Monks concerning the following question:
Environment (don't laugh, if I could change I would)...
Overview...
A require 'fileX.pl' statement only seems to work when run from the command line. Not when run as a CGI through the SunOneWebServer. (when run as a CGI it seems to cause the termination of my CGI script?)
Details...
I have a simple procedure that just returns an array of files in a directory and displays them ($cgi is a CGI object that is visable by this proc)
sub getVcolFileNames{ my @vcolFileArray; opendir DH, $vcol_dir or die "Cannot open $vcol_dir: ($!)\n"; foreach $file (readdir DH) { next unless $file =~ /\.vcol$/; push @vcolFileArray, $file; print $cgi->p("$file"); } closedir DH; return @vcolFileArray; }
If I put this code in my main CGI file it is executed perfectly and the file names are printed to the web browser.
However, if I put the code in a separate file and then use...
... to suck in the subprocedure and then call it from my CGI, the CGI is not processed any further than the require statement. But... if I execute the CGI from the command line it works fine and the subprocedure (from the require file) is called and executed normally.require 'vcol-utils.pl'
I have the following at the top of my CGI...
use CGI; $cgi = new CGI; use lib('.'); print $cgi->h1("Test1"); require 'vcol-utils.pl'; print $cgi->h1("Test2");
... the word "Test2" is never displayed when run as a CGI but the word "Test1" is??
Any pointers/views/help on this?
M
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: require fails in CGI
by sri (Vicar) on Oct 10, 2003 at 18:03 UTC | |
by heezy (Monk) on Oct 10, 2003 at 18:31 UTC | |
by sandfly (Beadle) on Oct 10, 2003 at 20:22 UTC | |
by PodMaster (Abbot) on Oct 10, 2003 at 21:14 UTC | |
|
Re: require fails in CGI
by liz (Monsignor) on Oct 10, 2003 at 17:59 UTC | |
|
Re: require fails in CGI
by Aristotle (Chancellor) on Oct 10, 2003 at 18:01 UTC | |
by heezy (Monk) on Oct 10, 2003 at 18:24 UTC | |
by Aristotle (Chancellor) on Oct 10, 2003 at 18:45 UTC | |
|
Re: require fails in CGI
by hardburn (Abbot) on Oct 10, 2003 at 20:05 UTC |