Help for this page
m{$location/?$}
my $file = 'some_filename'; my $location = 'some_filename/'; ... $location =~ s{/$}{/?}; # If a trailing / is found, append a ? to it. if( $file ~= m{$location$} ) { # Do your stuff }