use strict; open (INFILE, $ARGV[0]) or die "Unable to open file '$ARGV[0]' - $!"; while() { print replace($_); } close (INFILE); sub replace { my $line = shift; chomp ($line); $line =~ s/data|=|detector//g; return $line; } #### xyzzy data abc detector = data hooplah = enddata #### C:\>perl a.pl test.txt > out.txt #### xyzzy abc hooplah end