hello list,

I am trying to find if an element in one primary file (transformed to array) 
is included in two other different secondary files (transformed to arrays, 
too); the result is going to be printed as 1 or 0:

...
#creating arrays from its text files
@img_array=<IMATGES>; @dict_array=<DICT>; @in_array=<IN>;
#creating hashes from its arrays
foreach $in (@in_array) {chomp($in); $in_hash{$in}= 1;}
foreach $in (@dict_array) {chomp($in);$dict_hash{$in}= 1;}
foreach $in (@img_array) {chomp($in);$img_hash{$in}= 1;}
#searching primary element in secondary hashes
while (($key, $value) = each %in_hash) {
if (exists $dict_hash{$key}) {$dic_flag="1";}else {$dic_flag="-1"}
if (exists $img_hash{$key}) {$img_flag="1";}else {$img_flag="-1";}
#printing result
print "$img_flag, $dic_flag\n";
...

but it seems 'exists' function doesn't fly to do this -the element isn't 
always found into the secondary hashes. Any suggestion of why it doesn't and 
how to do it?

Your help is very much appreciated.

-- 
Xavier Mas

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to