in reply to One to one relationship
This code here can let you treat all the right and left values as keys and as values of each other, then you may want to use the hash as a search dictionary:
#!/usr/local/bin/perl #title "One to one relationship"; use strict; use warnings; use diagnostics; my %hash; while(<DATA>){ next unless /"(\w+)".*"(\w+)"/gs; $hash{$1}=$2; $hash{$2}=$1; } use Data::Dumper; print Data::Dumper->Dump ([\%hash]); __DATA__ "ger" <--> "german" "ara" <--> "arabic" "eng" <--> "english"
here's the output:
$VAR1 = { 'arabic' => 'ara', 'ara' => 'arabic', 'ger' => 'german', 'german' => 'ger', 'english' => 'eng', 'eng' => 'english' };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: One to one relationship
by ack (Deacon) on Oct 30, 2009 at 16:16 UTC |