Hi All,

I have a curious problem with open:

#!/usr/bin/perl $^W=1; use CGI; $| = 1; print "Content-type: text/html\n"; print "Hello, World!\n"; open ($in, "<", "source.list") or die "can't open file: $!"; @src_name = grep /^[A-B]/, <$in>; close $in; print $src_name[0]; print $src_name[$#argument];
It runs fine on command line:
#./test2.pl Content-type: text/html Hello, World! A02008P2350 BSW30905
But if I run it as a cgi script, ie. pointing my browser to http://lapakahi/csodb/test2.pl, it fails to open the file source.list:
Server error! The server encountered an internal error and was unable to complete yo +ur request. Error message: can't open file: No such file or directory at /srv/www/csodb/test2.pl +line 7. , If you think this is a server error, please contact the webmaster. Error 500 lapakahi Thu Oct 28 10:24:57 2010 Apache/2.2.0 (SuSE)
I made sure the file source.list is in the same directory as the script test2.pl, and it is readable by all. Also tried using absolute path for the file. Same result.

Any suggestions and advices will be greatly appreciated.


In reply to curious problem with open by hihilo

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.