English and translated strings are separated by a tab character. I found this and managed to put together the following code to read the file into a hash array:Retire a document Dokument deaktivieren Remove a document from the knowledge base Dokument aus der Knowledg +e Base entfernen Promote document retirement Dokument deaktivieren Document Expired Dokument abgelaufen
As far as I can tell, the hash is created correctly (otherwise please tell me), and the keys are populated by the English strings and the values by the translated ones.use strict; use warnings; open (FILE, "extract_tab.txt") or die "$!\n"; my %hash; while (my $line = <FILE>) { chomp($line); my ($enu, $deu) = split /\t/, $line; $hash{$enu} = $deu; } for my $key (keys %hash) { print "$key\n"; } for my $value (values %hash) { print "$value\n"; }
I now want to identify those keys that have identical values, and print them out. Something like "English strings 'Retire a document' and 'Promote document retirement' have the same translation ('Dokument deaktivieren')". I have been trying along the lines of the answers provided to this post, but I am getting stuck.
is giving me this error: Can't use string ("Dokument aus der Knowledge Base ") as a HASH ref while "strict refs" in use at hashtest.pl line 18, <FILE> line 4. Could someone help me understand? Or any hints for a different approach if it makes things easier? Thanks.#my %seen; for my $key (keys %hash) { my $value_key = "@{[values %{$hash{$key}}]}"; #print "$value_key\n"; }
In reply to Find duplicate values in hash by moff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |