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:
Output file TestFinal.txt is empty. Am I doing anything wrong?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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Replace many array element with another corresponding array element in a file
by Kenosis (Priest) on Oct 18, 2012 at 05:39 UTC |
In Section
Seekers of Perl Wisdom