use strict; use warnings; open (IN1, "; while () { foreach my $i (0..$#nets){ my $var1= $nets[$i]; print "matched" if m/$var1/; } }