A file contains some text with a header. I can grab the header okay. What I want to do is write the entire rest of the file to a new one.
The problem is, it only writes the last line to the new file.
Text File (real one would contain a lot more)
Expand|Select|Wrap|Line Numbers
- Aaaaaa
- aaaaaaaa aaaaaaaa aaaaaaaa
- bbbb bbbb bbbb bbbb bbbb
- dddddddddd dddddddddd
Expand|Select|Wrap|Line Numbers
- use strict;
- use warnings;
- use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
- print "Content-type: text/html\n\n";
- ## NOTE: for Perl 5.6 and earlier
- my $txf="file.txt";
- my $opfile="opf.txt";
- # get first line
- open(TXF,"$txf"); my $title=<TXF>; close TXF;
- # Get rest and write to new file
- open(TXF,"$txf");
- readline(TXF); # ignore first line
- while(<TXF>) {
- open(OPF,">$opfile");
- print $_, "<br>"; # good to screen
- #### --- need something here but do not know what ????
- print OPF $_; # only writes last line into file
- close OPF;
- }
- close TXF;
- # Finish
- print qq~<h2>Done</h2>~;
- exit;
Thanks.