A Diumenge 14 Gener 2007 12:33, [EMAIL PROTECTED] va escriure: > > A Diumenge 14 Gener 2007 11:20, Xavier Noria va escriure: > >> Xavier, this is being inefficient. > >> > >> If you don't send a minimal example together with data example that > >> reproduces the issue this is a come and go of second-guesses, which > >> is a waste of time. Please send them so we can go straight to > >> understand what happens. > >> > >> -- fxn > > > > Thank you for your interest, Xavier, but actually that's all what's > > about. I > > can send you the long text files (about 3 000 entries each one), but the > > program the whole program is the one I send (with the string and file > > handlers pointing to the files). The output of that small program is also > > just a printing to an output file. > > > > What else do you need? > > Your problem explanation is not self-contained. It could happen that the > status of open() is not checked, it could happen that files have different > newline conventions and some lines had spurious CRs whereas some others > don't, the files could have the wrong name in the script, a thousand > possibilities we are not going to explore by trial and error trough > email.... > > This is a list where people have years of experince debugging by email and > IRC, please just follow our advice, let us guide the debugging. > > Please send a self-contained snippet that reproduces the issue. Turn > strict and warnings on, and cut the minimal lines of your data files that > reproduce the problem. I say minimal so we can focuse on the problem, this > needs some little effort from your side. If you can, upload them somewhere > and post links to the files so that newlines, non-ascii, etc. is > preserved. > > -- fxn
Xavier, That's the program in full and a sample of the files (same as before): dict.txt: house, man, woman, kid, kitchen img.txt: ball, dog, cat, lion in.txt: woman, lion, dog use warnings; use strict; #variables declaration my $img; my $dict; my $in; my @img_array; my @dict_array; my @in_array; my %in_hash; my %dict_hash; my %img_hash; my $value; my $key; my $dict_flag; my $img_flag; my $projecte_out; #creating arrays $img="/home/xavier/Documents/Informàtica/lemes_nous/img.txt"; $dict="/home/xavier/Documents/Informàtica/lemes_nous/dict.txt"; $in="/home/xavier/Documents/Informàtica/lemes_nous/in.txt"; open (IMATGES, $img);open (DICT, $dict);open (IN, "$in"); @img_array=<IMATGES>; @dict_array=<DICT>; @in_array=<IN>; close(IMATGES); close(DICT); close(IN); 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 entries while (($key, $value) = each %in_hash) { if (exists $dict_hash{$key}) {$dict_flag="1";} else {$dict_flag="-1"} if (exists $img_hash{$in}) {$img_flag="1";} else {$img_flag="-1";} #printng results if ($img_flag eq "1" && $dict_flag eq "-1") { $projecte_out= "I1D0\n"; print $projecte_out;} if ($img_flag eq "1" && $dict_flag eq "1") { $projecte_out= "I1D1\n"; print $projecte_out;} if ($img_flag eq "-1" && $dict_flag eq "-1") { $projecte_out= "I0D0\n"; print $projecte_out;} if ($img_flag eq "-1" && $dict_flag eq "1") { $projecte_out= "I0D1\n"; print $projecte_out;} } and this are the results: I0D0 I0D0 I0D0 Cheers, -- Xavier Mas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/