Please send questions to
st10@humboldt.edu .
#!/usr/bin/perl -w
#######################################################
# lect06_filehandle_output3
#
# adding using an output filehandle to class8_06_filehandle_input1
#
# modified by Sharon Tuttle from "Learning Perl",
# by Schartz and Phoenix
#
# last modified: 9-28-04
#######################################################
# let's say that this reads from a previously-created counter file
# yes this works...
# -e "/home/st10/counters/lect06_08_counter" or die "UGH!";
open COUNTER, "< /home/st10/counters/lect06_08_counter"
or die "Cannot open lect06_08_counter: $!";
chomp($ct = <COUNTER>);
print "current counter value is: $ct\n";
close COUNTER; # close reading filehandle
# ...and now open writing filehandle
open COUNTER, "> /home/st10/counters/lect06_08_counter"
or die "Cannot open lect06_08_counter for writing: $!";
select COUNTER;
$ct++;
print STDOUT "reset counter to: $ct\n";
print "$ct\n";
close COUNTER; # close output filehandle
select STDOUT;
# end of lect06_filehandle_output3