sub replace (\%\@) { my ($repl_ref, $text_ref) = @_; my $repl_str = join '|', (keys %$repl_ref); for (@$text_ref) { s/($repl_str)/$$repl_ref{$1}/g; } }