in reply to How do I append or write to the end of a file?
!/usr/bin/perl use strict; open (FILE, "file") || die "File does not exist\n"; my @file = <FILE>; my $file = @file; close (FILE); open (FILE, ">file") || die "File does not exist\n"; for (my $n = 0; $n <= $file; $n++) { $_ = $file[$n]; print FILE $_; } print "add whatever"; --> should be print FILE "add whatever"; print "here\n"; --> should be print FILE "here\n"; print "to end of txt.\n"; --> should be print FILE "to end of txt.\n"; close (FILE);
Originally posted as a Categorized Answer.
|
---|