You cannot know that it's opening the files correctly unless you check the return values of your open calls. It's entirely possible that the script opens the files properly when run via the command line (with your user permissions), and fails based on permissions when run by the webserver (who usually runs as 'nobody').

Use the ever-popular "or die "Couldn't open the file: $!";" construct after your opens to ensure things are hunky dory. See perlopentut for examples. Failing to check the return value of open is a very common mistake among beginners. It is, however, one of those absolutes in life: always always always check the return value of open. Even if you're sure the file will open, even if you don't care if it opens or not, check; develop the habit.

If the script dies once you check the return value of open, then you can at least check the server's error log to see what error is being reported.

It also might not hurt to print out all of the parameters captured by the CGI module, so that you can ensure that the params are what you think they are.


Dave


In reply to Re: Interesting CGI Problem... by davido
in thread Interesting CGI Problem... by Spidy

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.