in reply to comparing array vs file

This may be caused by not taking account of newlines on the lines read from the file. Include a chomp and see if that helps.
#!/usr/local/bin/perl use strict; use warnings; my @array = qw{one three}; while(<DATA>){ my $var1=$_; chomp $var1; foreach my $var2 (@array){ if($var1 eq $var2){ print "line is $.\n"; } } } __DATA__ one two three four