Using foreach and multiple arrays

I wrote a function in perl where it reads in each file in a directory and checks for a tag:

Each file should have one of the sequences of tes tags as defined in these arrays.
I am trying to do the following - if the tag sequence in the match does not follow any one of the arrays, then continue onto the next array to see if there is a match there.

I could possibly store the tag values from the file into an array then compare.  But the problem is that I only need to match the first 4 or 5  tags.  Each file consists of 10 - 15 tags.

What would be the best way to do this?

@testarray1 = qw (QW1, LS3, DE3, TER);
@testarray2 = qw (GF3, LS3, RTL, ST);
@testarray3 = qw (LS5, R3E, DE3, EEW);
@testarray4 = qw (FFL, DRE, ASD, FGE, GFH, SDF);

open(FILE, "$filename")
#read all lines
while(<FILE>)
{
  foreach $entry (@testarray1)
 {
    if (/\<tes/ && /type=\"$entry\"/)
    {
          //matches!  check the next entry
    }
    else
    {
         //stop checking this array, and check the next array
  }
    }
jeweeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
my $n=0;
for( \@testarray1, \@testarray2, \@testarray3, \@testarray4 ){
   $n++;
   push @test,{map{$_,$n}@$_}
}
{local @ARGV=grep -f,<directory/*>;
 while( <> ){
    if( /<tes/ and my($entry)=/type="([^"]+)"/ ){
       for( @test ){ if( my $n=$_->{$entry} ){ print "$ARGV matches array $n\n" }
    }
 }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
perl -Mdiagnostics -w -e "@testarray1 = qw (QW1, LS3, DE3, TER);"
Possible attempt to separate words with commas at -e line 1 (#1)
    (W qw) qw() lists contain items separated by whitespace; therefore
    commas aren't needed to separate the items.  (You may have used
    different delimiters than the parentheses shown here; braces are also
    frequently used.)
   
    You probably wrote something like this:
   
        qw! a, b, c !;
   
    which puts literal commas into some of the list items.  Write it without
    commas if you don't want them to appear in your data:
   
        qw! a b c !;
   
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.