#!/usr/bin/perl use strict; use warnings; # WORKS my $file = 'C:/tmp'; my $regex = 'C:/tmp'; if ($file =~ m/$regex/i) { print "\nTest with forward slashes -- If stmt is true...\n"; } # FAILS $file = 'C:\tmp'; $regex = 'C:\tmp'; if ($file =~ m/$regex/i) { print "\nTest with backslashes -- If stmt is true...\n"; }