I forget if the error I have seen shows up the way you describe it or not. I do not know how your GD module is compile, or if it is a shared library version of libgd... But maybe it is an LD_LIBRARY_PATH issue...

Where is your libgd library installed? Is it in /usr/local/lib? You could try doing something like the following at the top of your perl script:

my $LIB = defined $ENV{LD_LIBRARY_PATH} ? $ENV{LD_LIBRARY_PATH} : ""; $ENV{LD_LIBRARY_PATH} = "/usr/local/lib:$LIB";

If that doesn't work, you can use an old trick to force LD_LIBRARY_PATH to get set:

#!/bin/sh LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH exec /usr/local/bin/perl -x -S $0 ${1+"$@"} # -*-perl-*- #!perl -w use GD; ....

Anyways, I feel like the "module not found" error is masking the real error that the module *can* be found, but can't be loaded because of other shared libraries needed for the module to work... I think Perl just displays the wrong error.

The reason it works from the command line is because your shell environment is setup different than the Apache environment. When Apache starts, it is started usually from a startup script as root, which consequently has few environment variables set, meaning LD_LIBRARY_PATH is not likely defined.

Hope this helps.
Zucan


In reply to Re: Trouble with Perl CGI script by Zucan
in thread Trouble with Perl CGI script by chakkaln

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.