in reply to Re: Re: Help already received and request for more
in thread Keeping form information in CGI

Thank you for that information, I was using the print line with the filehandle but decided
that in the interest of debugging I'd just have it print on the bottom of the webpage (easier to see if it worked).

My real question here is why after the open line the print doesn't happen. Regardless of where I'm printing the print just does not occur.
I have previously opened and closed two other filehandles in the program and there are something like 10 global arrays in the program. I don't know if any of that is important but thought I'd tell you anyway.

Replies are listed 'Best First'.
Re: Clarification and reiteration
by wardk (Deacon) on Jul 04, 2001 at 02:04 UTC

    I see you are printing only if the if-test is false, have you tried seeding the file? i.e. open, then print one line, that way if the if-test is never true (another possiblity) you get something. Since it doesn't print to the browser, I would suggest that you aren't getting the test you think you should be in the if.

    keep plugging away...and remember timtowtdi! :-)

      I tried this code and none of the print lines printed.
      open (ORGIDATA, ">../states/orig$$") or die "Couldn't open! $!"; print ORIGDATA "pre-for, pre-if"; print "pre-for, pre-if"; for (my $k = 0; $k < @classid; $k++) { print ORIGDATA "pre-if"; print "pre-if"; if ($classid[$k] != $classid[$k-1]) { print $classid[$k], " ", @{$class[$k]}, " ", $location[$k], " +", $credits[$k], "<br>\n"; } print ORIGDATA "post-if"; print "post-if"; } print ORIGDATA "post-for, post-if"; print "post-for, post-if"; #close ORGIDATA; print ORIGDATA "post-all"; print "post-all";

      However when I use this code:

      #open (ORGIDATA, ">../states/orig$$") or die "Couldn't open! $!"; #print ORIGDATA "pre-for, pre-if<br>"; print "pre-for, pre-if<br>"; for (my $k = 0; $k < @classid; $k++) { # print ORIGDATA "pre-if<br>"; print "pre-if<br>"; if ($classid[$k] != $classid[$k-1]) { print $classid[$k], " ", @{$class[$k]}, " ", $location[$k], " +", $credits[$k], "<br>\n"; } # print ORIGDATA "post-if<br>"; print "post-if<br>"; } #print ORIGDATA "post-for, post-if<br>"; print "post-for, post-if<br>"; #close ORGIDATA; #print ORIGDATA "post-all<br>"; print "post-all<br>";
      I get the following output:
      pre-for, pre-if
      pre-if
      29022 MW5 MI-100 3
      post-if
      pre-if
      post-if
      pre-if
      26532 TTh4 ARC-205 3
      post-if
      pre-if
      32330 MW6 VH-105 3
      post-if
      pre-if
      20617 TTh7 PHY-LH 3
      post-if
      pre-if
      30257 MTh2 ARC-204 3
      post-if
      post-for, post-if
      post-all
      which is correct.

      I'm stumped by this, I'm going to start looking for other ways to do this but I'd really like an explanation for this behavior.
      Thanks for any and all help.

          -Etan

        open (ORGIDATA, ">../states/orig$$") or die "Couldn't open! $!"; print ORIGDATA "pre-for, pre-if";
        Note that you are opening ORGIDATA and writing to ORIGDATA. You've transposed the GI. So you're opening ok, then writing to a non-existant handle