Gunnar Hjalmarsson wrote:
Gowri Chandra Sekhar Barla, TLS, Chennai wrote:
I am unable to modify the input file ,

In addition to other posted solutions, I thought I'd mention the possibility to open the file in read/write mode.

    open my $FH, '+<', $filename or die $!;
    my @lines = <$FH>;
    truncate $FH, 0 or die $!;
    seek $FH, 0, 0 or die $!;
    foreach ( @lines ) {
        s/FRCC/FRE/;
        print $FH $_;
    }

Or just use Tie::File:

tie my @lines, 'Tie::File', $filename or die "Cannot open '$filename' $!";

s/FRCC/FRE/ for @lines;

untie @lines;



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to