The most important paragraph of your post is the following:
This works in a regular perl script. But in my cgi, it fails. Putting the above code in a separate script which is called by the cgi, writes to file and allows for the cgi to read the file also fails.
Whenever you experience such a situation, it's time for print (or any other command which allows you to get debug output).

Add print STDERR lines to your program to find out what is happening where.

  • Is $google undef?
  • Is $key different?
  • What is in $hashref1 (Data::Dumper may be a good help for this)?
  • Is your program not looping for any reason?
  • If everything else fails, compare the environments (%ENV) as this is the biggest difference between a shell and a CGI situation
  • Your programm may also succeed, but the webserver cancels the request before any output gets through (usually after 5 min, but it's configurabel down to 1 sec.) If your last line print STDERR "Done\n"; isn't shown, this could be the reason

  • WebService::Simple doesn't provide a ->dump method as far as I looked at it, but using Data::Dumper's Dumper() function on it may be worth a try. Expect a huge output, but looking through it may get you an HTTP error message or something else useful.

    If everything fails and you don't get any new indeas, please add an exact description what you mean by "fails", including the error message, if any.


    In reply to Re: Google Images via CGI by Sewi
    in thread Google Images via CGI by dime

    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.