N
nymphnode
Hi,
I'm not sure what I'm doing wrong with my output redirection, and I've
done something similar before which had worked so I'm at a loss. This
is the part of my code that is not working:
------ *snip * ----------
foreach my $sub ( keys %RTs ) {
$out = $sub".1d";
open(OUT,">$out") || die "Cannot open $out to write: $!\n";
print OUT "yay";
if ( $sub eq "key") {
print OUT "booo";
print "in if clause";
}
close(OUT);
}
-----------------------------
Basically, it will print "yay" (before the if block) into the output
file, but it won't print "booo" (in the if block) to the output file
even though I'm obviously going into the loop because I get "in if
clause" printed to the terminal. It seems like the output file is
closing when I get into the if loop...why and how do I get around this?
Or is there something else I'm doing wrong?
Thanks!
I'm not sure what I'm doing wrong with my output redirection, and I've
done something similar before which had worked so I'm at a loss. This
is the part of my code that is not working:
------ *snip * ----------
foreach my $sub ( keys %RTs ) {
$out = $sub".1d";
open(OUT,">$out") || die "Cannot open $out to write: $!\n";
print OUT "yay";
if ( $sub eq "key") {
print OUT "booo";
print "in if clause";
}
close(OUT);
}
-----------------------------
Basically, it will print "yay" (before the if block) into the output
file, but it won't print "booo" (in the if block) to the output file
even though I'm obviously going into the loop because I get "in if
clause" printed to the terminal. It seems like the output file is
closing when I get into the if loop...why and how do I get around this?
Or is there something else I'm doing wrong?
Thanks!