Hi All,
I have written a perl cgi script which draws a image using the perl GD module. This scripts works fine when run form the command line. When I run this from browser, I get an internal server error. When I cheked the error logs, it tells me that it cannot locate GD module. Why is this happening. Does it need to set some thing to tell where the modules are located?

perl script simpleImage.cgi
#!/usr/local/bin/perl use GD; use CGI ':standard'; # This creates a Web GIF image on the fly # create a new image $im = new GD::Image(1000,100); # allocate some colors $white = $im ->colorAllocate(255,255,255); $black= $im ->colorAllocate(0,0,0); $red = $im ->colorAllocate(255,100,0); $blue= $im ->colorAllocate(0,150,255); $yellow= $im ->colorAllocate(255,200,0); $pink= $im ->colorAllocate(150,0,150); $im->filledRectangle(10,5,990,15,$pink); $im->arc(10,10,10,10,0,360,$black); $im->fill(10,10,$white); $im->arc(990,10,10,10,270,90,$black); $im->fillToBorder(990,10,$black,$pink); # Convert the image to GIF and print it on standard output #binmode STDOUT; print "Content-type: image/gif\n\n"; print $im->gif;
Address in the browser

http://localhost:8080/cgi-bin/simpleImage.cgi

Error recorded in the log files
[Fri Jul 29 00:25:57 2005] [error] [client 127.0.0.1] Premature end of + script headers: /home/nagesh /apache/cgi-bin/simpleImage.cgi Can't locate GD.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.6/ +i686-linux /usr/local/lib/per l5/5.8.6 /usr/local/lib/perl5/site_perl/5.8.6/i686-linux /usr/local/li +b/perl5/site_perl/5.8.6 /usr/ local/lib/perl5/site_perl .) at /home/nagesh/apache/cgi-bin/simpleImag +e.cgi line 3. BEGIN failed--compilation aborted at /home/nagesh/apache/cgi-bin/simpl +eImage.cgi line 3.
Any help will be greatly appreciated.
Thanks
Nagesh

fixed formatting by holli


In reply to 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.