in reply to
Re: Replace many array element with another corresponding array element in a file
in thread Replace many array element with another corresponding array element in a file
I tried the following:
my %hashvariable;
@hashvariable{@variable} = @vardescription;
my $TestText;
{
local $/;
open( my $in, '<', "Test.txt" ) or die "cannot open Test.txt $!";
my $TestText = <$in>;
close $in;
}
$TestText =~ s/$_/$hashvariable{$_}/g for keys %hashvariable;
open( my $out, '>', "TestFinal.txt" ) or die "cannot create TestFinal
+$!";
print $out $TestText;
close $out;
Output file TestFinal.txt is empty. Am I doing anything wrong?