UPDATE: Athanasius beat me to the punch with both a 'welcome' and a better 'Perl-ish' solution!
Violet, first off, welcome to the Monastery and to the wonderful world of Perl programming.
First off, start all your scripts with 'use strict' and 'use warnings', that will help you catch many errors and incorrect or troubling syntax that may impact your output and obfuscate troubleshooting.
You should use the three-argument 'open' for better security in your code.
The main problem I see is that you operate on FILE while in the LIST loop. You should do the operations on FILE outside the LIST loop. I've provided reference below that works on a small test data set I made up (assuming what your input files look like based on your question and code).
#! C:\Perl\bin\perl -w use strict; use warnings; open my $LIST, '<', "list.txt"; my @mylist = <$LIST>; open my $FILE, '<', "file.txt"; my @myfile = <$FILE>; foreach my $file (@myfile) { chomp $file; my @temp = split (/\t/, $file); foreach my $list (@mylist) { chomp $list; if ($temp[1] eq $list) { print "$file\n" } } }
In reply to Re: Looping in a Loop
by VinsWorldcom
in thread Looping in a Loop
by Violet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |