in reply to Re: Re: for loop over large BLOCK keeps failing
in thread for loop over large BLOCK keeps failing

strict could maybe help with this problem, I don't know.
But you SHOULD know strict, have a look at the docs here.

You can have more diagnostic messages from perl if you use diagnostics.

I spotted one error in your code:
In the inner loop the line

$body = get("@img[$i]");
shoud probably be
$body = get("$img[$i]");
since you probably want to get one array element.

Replies are listed 'Best First'.
Re:{4} for loop over large BLOCK keeps failing
by jeroenes (Priest) on May 02, 2001 at 13:09 UTC
    C'mmon ppl, I know you can do better than that.

    cdherold: you should keep you declarations up top. So lower the for-loop below the use.

    Furthermore, keep the sub routine outside the loops. Clean up that one, so it doesn't depend on vars outside the sub (is a good idea in general)

    Look at the MAIL pipe. I don't think open closes MAIL before opening it, but I'm not sure. So *always* check whether a open fails with:

    open BLAH, "some_expr" or die "Could not do some_expr: $!";
    The behaviour cdherold describes could be well due pipe issues. The first print has some effect, but the others are just added to the body or printed to void.

    Well, these are quickies as well. But should give cdherold a start.

    Cheers,

    Jeroen
    "We are not alone"(FZ)

Re: Re: Re: Re: for loop over large BLOCK keeps failing
by cdherold (Monk) on May 02, 2001 at 13:07 UTC
    Thanks for the links to diagnostics and to strict ... and the typo in the code.

    I'm still very confused, however, on why this code doesn't work with the for loop. If I comment out the two lines  for ($loop=0;$loop<=3;$loop++){ and the closing bracket } the code works fine. It seems the only problem is in the for loop statement.

    I can't see my diagnostics ... I assume because I'm running my perl programs via the web where I just get an internal error banner when the program crashes. How do I go about seeing the diagnostics output in this case? Currently what I do to check to see if the program works is to upload it to the server and then run it by going to its url and refreshing the browser. Do you know how I could get the diagnostics to print out? cdherold

      Here are two things that should help immensely with debugging your CGI scripts...

      First, before you upload your script to the web server, make sure it compiles: perl -c myscript.cgi

      Second, use CGI::Carp to get more useful output when your script dies: use CGI::Carp qw/ fatalsToBrowser /; CGI::Carp by itself will produce nicely formatted error messages in the server's error log. Importing fatalsToBrowser will cause those errors to be sent to the browser as well.

      You can also use CGI::Carp's carpout method to create your own private error log in an easily accessible place, rather than using the server's.

        thank you very much for the cgi::carp hint. very helpful.

        cdherold