dave498186
Technical User
First of let me start off by saying that I'm new to perl and new to the forums. Been self learning it for about 3 weeks on and off. Just started off making some basic programs such as a dice rolling game and a check book.
My question is for the check book. I have 3 entries in the checkbook.txt file already. In my program I access it and want to append a new withdrawl to the checkbook.txt file and then at the end of the program open up the updated file and print for visual proof of an update.
However, after updating the file and then printing, it only prints the last line that was in the .txt file before it appended. So I was hoping someone would be able to check the coding and see what I was doing wrong. It's only a few lines. Thanks in advance.
My question is for the check book. I have 3 entries in the checkbook.txt file already. In my program I access it and want to append a new withdrawl to the checkbook.txt file and then at the end of the program open up the updated file and print for visual proof of an update.
However, after updating the file and then printing, it only prints the last line that was in the .txt file before it appended. So I was hoping someone would be able to check the coding and see what I was doing wrong. It's only a few lines. Thanks in advance.
Code:
#! usr/bin/perl
open(OUTPUT, '>>checkbook.txt') || die "Couldn't open the requested file';
print OUTPUT "Withdrawl \$150\n";
close OUTPUT;
open (UPDATED, 'checkbook.txt') || die "Couldn't open the requested file';
$OpenFile = <UPDATED>;
print $OpenFile;
close UPDATED;