my $check = 'test.zip'; (my $test = $check) =~ s/\.zip$//; # strip the zip $_ = 'test'; print "match" if /^$test/; # Note no grep - no need