NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

This node was taken out by the NodeReaper on Apr 26, 2008 at 01:33 UTC
  • Comment on Reaped: Replace text in one file with text from another

Replies are listed 'Best First'.
Re: Replace text in one file with text from another
by jwkrahn (Abbot) on Apr 25, 2008 at 23:03 UTC
    #!/usr/bin/perl use warnings; use strict; my $infile = 'test.txt'; open INFO, '<', $infile or die "could not open '$infile' $!"; open FILEA, '<', 'outputfromvariantparser1.txt' or die "could not ope +n 'outputfromvariantparser1.txt' $!"; open FILEB, '>>', 'output.txt' or die "could not open 'output.txt' $!" +; my @raw_data = <FILEA>; while ( my $line = <INFO> ) { $line =~ s/TEXT TO BE REPLACED.*/$raw_data[0]/s; print FILEB $line; push @raw_data, shift @raw_data; }