$ perl -wle' my $file = "movie.avi"; my $fileformat = ".avi"; if ($file =~ m/($fileformat)/) { print "match"; }' match