Does this help you understanding the script you copied?open (LIST1, $list1) or die "cannot open $list1"; open (LIST2, $list2) or die "cannot open $list2"; while (<LIST1>) { #get all the variables for line from LIST1 my ($c,$d,$e,$f,$g,$h) = split(/"\t"/); # do you mean "\t" or \t? # are there " in the file? $flag=0; #reset the flag # which flag? my %list2key= (); while (<LIST2>) { ($a, $b) = split(/"\t"/); $list2key{$a} = $b; } # This will read your second file once for the # first line of your first file # As soon as you have the second line of you first # file, it will forget about the second file! # Maybe you should move this loop out of the # LIST1-loop if (exists $list2key{$c}) { $name = $list2key{$c}; #print out to screen as a test then to a file later print "$name $ +d $e $f $g\n"; $flag=1; } }
In reply to Re: Re: matching data with 2 files
by Skeeve
in thread matching data with 2 files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |