A Dissabte 13 Gener 2007 20:38, John W. Krahn va escriure: > xavier mas wrote: > > Here's an example: > > in (file, array and hash) contains: "woman, lion, ball" > > img (file, array and hash) contains: "ball, dog, cat, lion". > > dict (file, array and hash) contains: "house, man, woman, kid, kitchen, > > lion" > > > > Comparing in with dict ans img, I'll expect as a result (all previous > > code is between the while curly braces): > > -1, 1 > > 1, 1 > > 1, -1 > > but the result is, instead: > > -1, -1 > > -1, -1 > > -1, -1 > > that means never finds it. > > > > I hope this is enough data. > > I simplified your code: > > #!/usr/bin/perl > use warnings; > use strict; > use Inline::Files; > > #creating hashes from files > my %in_hash = map { chomp; $_, 1 } <IN>; > my %dict_hash = map { chomp; $_, 1 } <DICT>; > my %img_hash = map { chomp; $_, 1 } <IMATGES>; > > #searching primary element in secondary hashes > while ( my ( $key, $value ) = each %in_hash ) { > #printing result > print exists $img_hash{ $key } ? 1 : -1, > ', ', > exists $dict_hash{ $key } ? 1 : -1, > "\n"; > } > > __IN__ > woman > lion > ball > __DICT__ > house > man > woman > kid > kitchen > lion > __IMATGES__ > ball > dog > cat > lion > > > And the results I get are (I get the same results before I modified the > code): > > 1, 1 > -1, 1 > 1, -1 > > > So are you sure that the code you posted is the code you are using? > > > > > John > -- > Perl isn't a toolbox, but a small machine shop where you can special-order > certain sorts of tools at low cost and in short order. -- Larry Wall
Thank you, John. Yes, this is the code I use, but still doesn't work to me and I can't find the cause. -- Xavier Mas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/