in reply to problem with string substitution output

It should work like this:

#!/usr/bin/perl use warnings; use strict; my $echo = 'ECHO'; @ARGV == 2 or die "usage: $0 file1 file2\n"; open DFFILE, '<', $ARGV[ 0 ] or die "$ARGV[ 0 ]: $!"; my @lijst = sort map /^1\t([^\t\n]+)/, <DFFILE>; close DFFILE; open LIST, '<', $ARGV[ 1 ] or die "$ARGV[ 1 ]: $!"; chomp( my @listfiles = <LIST> ); close LIST; for my $word ( @lijst ) { for my $file ( @listfiles ) { open FILE, '<', $file or die "$file: $!"; open OUT, '>', "$file.out" or die "$file.out: $!"; reset; while ( <FILE> ) { ?^$word$? or s/$word/$echo/g; print OUT; } } }