in reply to Clarification and reiteration
in thread Keeping form information in CGI

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! :-)

Replies are listed 'Best First'.
Re: Re: Clarification and reiteration
by deryni (Beadle) on Jul 04, 2001 at 12:43 UTC
    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