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...

require 'vcol-utils.pl'

... 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.

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


In reply to require fails in CGI by heezy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.