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

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

Replies are listed 'Best First'.
Re: Re: Re: Clarification and reiteration
by wardk (Deacon) on Jul 05, 2001 at 19:19 UTC
    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