Hi,
Store all the contents of the file in an array and operate on the array.
There should be a better way(inline modification i guess using "-i" option).
#!/usr/bin/perl -w
use strict;
my @arr;
my $filename = "testtest";
open(FH,"<","$filename") || die "Could not open $filename\n";
@arr=<FH>;
$arr[$#arr] = "Put your new line here";
close (FH) || die "Could not close the $filename";
open(FH,">","$filename") || die "Could not open $filename\n";
print FH @arr;
close(FH) || die "Could not close $filename\n";
--Prasanna
[EMAIL PROTECTED] wrote:
Hi ,
there is an existing file and I need to append text to it ,only thing
is I need to remove the last line of existing file and then need to
append text.
I hope I am clear.If there are 6 lines in a file I have remove 6th line
and then need to append the text.
Thanks in advance
Arjun
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>