Well, if the file is not too big, a simple (but slightly convoluted) way to do that would be to read all the lines into an array, edit the first and last elements of the array, and then write the file back out again. Like so:
open IN, "<", "file.txt" or die "Cannot open file.txt for reading:$!\n
+";
my @lines = <IN>;
$lines[0] =~ s/,+$/,/;
$lines[-1] =~ s/,+$/,/;
open OUT, ">", "file.txt" or die "Cannot open file.txt for writing:$!\
+n";
print OUT for @lines;
close OUT;
| [reply] [d/l] |
Thanks alot for the replies
I got the solution
Sridhar
| [reply] |
Hello
The script is working fine thanks for the script. Any idea if the file is big how to achieve this task
Thanks in advance
Sridhar
| [reply] |
Hello
If the file is big is there way to do this task...thanks again for your help
Sridhar
| [reply] |