in reply to Modifying File in the Middle

You can do it like this:

#!/usr/bin/perl use strict; use warnings; my $usage ="$0 <fileA> <fileB>\n"; my $fileA = shift or die $usage ; my $fileB = shift or die $usage; open(FILEA, '<', $fileA) or die "could not open $fileA\n"; open(FILEB, '<', $fileB) or die "could not open $fileB\n"; my $file_a_content; { local $/=undef; # unset input record separator to slurp all into a s +tring $file_a_content = <FILEA> ; close FILEA; } while (my $line = <FILEB> ) { $line=~s/SEARCHPATTERN/$file_a_content/; print $line; } close FILEB;

This will print to STDOUT, so use it like this:

$ middle_replacer.pl fileA fileB > fileC