in reply to Re^2: Find & Replace
in thread Find & Replace

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;

Replies are listed 'Best First'.
Re^4: Find & Replace
by mantra2006 (Hermit) on Aug 10, 2006 at 15:19 UTC
    Thanks alot for the replies

    I got the solution


    Sridhar
Re^4: Find & Replace
by mantra2006 (Hermit) on Aug 10, 2006 at 17:45 UTC
    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
Re^4: Find & Replace
by mantra2006 (Hermit) on Aug 10, 2006 at 17:20 UTC
    Hello


    If the file is big is there way to do this task...thanks again for your help
    Sridhar