Subject: | globs using character ranges match directory separators |
Date: | Sun, 07 Feb 2016 15:49:04 -0500 |
To: | bug-Text-Glob [...] rt.cpan.org |
From: | Jonathan Primrose <jprimros [...] gmail.com> |
Distribution name and version: Text-Glob-0.09
Perl version: (any - using 5.22.1)
Operating System vendor and version: Linux 3.18.7 (locally compiled, SLS distribution for last full install)
Problem Description:
When using a glob that includes a character range, the directory separator can be matched.
This behavior is inconsistent with the operation of globbing at a shell prompt, and with
perl's glob function. Similarly, the shell and perl's glob will never match a directory
separator explicitly listed in a character set.
Simple example:
use Text::Glob qw(glob_to_regex);
my $re = glob_to_regex('a[+-3]b');
my $test = 'a/b';
if ($test =~ m/$re/)
{
print "Buggy\n";
}
else
{
print "Good\n";
}
The directory separator should be removed from any character set when converting from the
glob pattern to a regex, both when explicitly listed in the character set, and when
implicitly included as part of a character range.