To add to wsfp's excellent answer, this is an almost classic case where a hash will make the code simpler and (probably) quicker:
#!/usr/local/bin/perl
use strict;
use warnings;
my %hash;
@hash{qw(one three)} = undef;
while(my $var1 = <DATA>){
chomp $var1;
if (exists $hash{$var1}) {
print "line is $.\n";
}
}
__DATA__
one
two
three
four