http://www.perlmonks.org?node_id=989375


in reply to Array Element Substitution

Short, ugly version below. Responsible error checking and file handling are left to the student.

#!/usr/bin/env perl use Modern::Perl; my @old = `cat old.txt`; chomp @old; my @new = `cat new.txt`; chomp @new; my %h; @h{@old} = @new; my $text = `cat log.txt`; $text =~ s/$_/$h{$_}/g for @old; print $text;

Aaron B.
Available for small or large Perl jobs; see my home node.