>>442
http://perldoc.jp/docs/perl/5.10.1/perlfaq5.pod

my %var = (FOO => 'bar');
open my $fh, '+<', $file or die $!;
read $fh => my $text, -s $fh;
$text =~ s/__([A-Z]+)__/$var{$1}/g;
seek $fh, 0, 0;
print $fh $text;
truncate $fh, tell;
close $fh;

open my $sfh, '<', $src_file or die $!;
open my $tfh, '>', $tmp_file or die $!;
while (<$sfh>) {
  s/__([A-Z]+)__/$var{$1}/g;
  print $tfh $_;
}
close $tfh and close $sfh or die $!;
rename $tmp_file => $src_file or die $!;