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


in reply to Re: Uer Perl Variable in file
in thread Uer Perl Variable in txt file

Or even

#!/usr/bin/perl use warnings; use strict; my %replace = (name => 'Joe', fun => 'a game'); my $search_for = join '|', map quotemeta, keys %replace; while (<DATA>) { s/\$($search_for)/$replace{$1}/g; print; }

I avoid nested loops where possible.