It's a funny thing ... the program will run through once and mail me the relevant press releases, but then there is some internal error when it tries to do the loop.
I came to the same results using perlmonkeys for my $loop(0 .. 3){ and for ($loop=0; $loop <=4; $loop++) {
I put strict in at the top with the other uses and that shut everything down. Realize here I am a perl neophyte. I've heard about strict before, but never seen it in use. Could use strict help my problem?
cdherold | [reply] [d/l] [select] |
$body = get("@img[$i]");
shoud probably be
$body = get("$img[$i]");
since you probably want to get one array element. | [reply] [d/l] [select] |
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) | [reply] [d/l] |
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
| [reply] [d/l] [select] |
Adding use strict; at the beginning of your script will catch all sorts of typos and bad things because it forces you to declare everything you use. eg:
my $temp = 'hello';
print $tmp;
would print nothing, because $tmp is not defined. Of course, you meant to print $temp, but if you don't use strict, this error will go unnoticed by Perl and you may miss it. This example is trivial, but if you had 100 lines of code, it could easily occur!
cLive ;-) | [reply] [d/l] |