#!/usr/bin/perl -w # file1=hash file2=dict file3=novo #André Santos, Ago2009 use feature "say"; $file1 = shift; open (HASH, $file1) or die("can find $file1\n"); my (%hash); while (){ if (/^(.*?)\s*;\s*(.*?)\s*$/) {$hash{$1} = $2;} #else {say STDERR "Falhou $1";} } close(HASH); $file2 = shift; $file3 = shift; my $replaced = 0; open(DICT, $file2); open(NOVO, ">$file3"); while ($line = ){ if ($line =~ /^(.*)\//){ chomp $line; if (defined($nova = $hash{$1})){ say NOVO "$line/$nova"; $replaced++;} #else {print NOVO $line;} } #else {print NOVO $line;} } close(DICT); close(NOVO); say STDERR "Substituições: $replaced";