search of string from an array in Perl

Hi All

I want to search a string from an array in Perl. If a match occurs, assign that string to a variable else assign 'No match'. I tried writing the script as follows but it's in vain. Please help me..

 #!/usr/bin/perl
    use strict;

    my $NER;
    my @text=("ORG","PER");

   my @NES=("I-PER","I-TIM","LOC","MISC","ORG","PER");

    for(my $k=1; $k<=29; $k++)
    {
        if ($text[0] eq $NES[k])
        {
                $NER = $text[0];
        }
        else
        {
                $NER="No Match";
        }
    }
  print $NER;

Expected Output:-

ORG

Thanks in advance.

Not the way I would do it but here is your code corrected:

#!/usr/bin/perl

use strict;

my $NER;
my @text=("ORG","PER");

my @NES=("I-PER","I-TIM","LOC","MISC","ORG","PER");

for(my $k=1; $k<=29; $k++)
{
if ($text[0] eq $NES[$k])
{
$NER = $text[0];
last;
}
else
{
$NER="No Match";
}
}
print $NER;

Thanks a lot. It worked. But can you please write in the way you would like to?

Not knowing anything else, going by only the data you posted and the desired output:

#!/usr/bin/perl

use strict;
use warnings;

my $NER = 'No Match';
my @text = qw(ORG PER);
my @NES  = qw(I-PER I-TIM LOC MISC ORG PER);

MAINLOOP: for my $text (@text){
   for my $nes (@NES){
      if ($text eq $nes) {
         $NER = $text;
         last MAINLOOP;
      }
   }
}
print $NER;

Thanks a lot.