I am trying to use the tr function specifying two arrays, as the to and from sets. the translation doesn't seem to be working, or i am not understanding it correctly. I am new to perl, so please let me know if i am doing something wrong
I load the arrays as (I know this part works):
open my $fh,'<',"${main_dir}/char_convert" or die "Cannot open allowed conversion file";
my @from_set;
my @to_set;
my @conversion;
while (my $lines = <$fh>) {
@conversion = split(" ",$lines);
push @from_set,$conversion[0];
push @to_set,$conversion[1];
}
#The variable $line holds the data I want converted:
my $statement;
my $result;
$statement = "tr\@from_set\@to_set\$line;"; # Setup the tr command
$result = eval($statement); # perform the conversion
print "$line\n";
the result is the same as the data going in. No conversion appears to have taken place. What am I doing wrong?
An example part of the data is "PICAÑA". The line in the conversion file is "Ñ N" So I expect to get out "PICANA", but I get the original data
Thanks for looking