jkeenan1 has asked for the wisdom of the Perl Monks concerning the following question:
I have a situation where I am unexpectedly getting the Unterminated \g... pattern in regex error message.
In one of my CPAN modules, I have source code in a constructor which tests for the existence of certain directories.
my @missing_dirs = ();
for my $dir ( qw| gitdir workdir outputdir | ) {
push @missing_dirs, $data{$dir}
unless (-d $data{$dir});
}
if (@missing_dirs) {
croak "Cannot find directory(ies): @missing_dirs";
}
In the test suite, I have code which composes a path to a non-existent directory and then demonstrates that I get the expected error message when I try to use that path as an argument to the constructor. I use File::Spec->catdir() to compose the path string in an operating system-agnostic way.
local $@;
$bad_gitdir = File::Spec->catdir('', qw| home jkeenan gitwork mist-compare |);
$args{gitdir} = $bad_gitdir;
$params = process_options(%args);
eval { $self = Devel::Git::MultiBisect::AllCommits->new($params); };
like($@, qr/Cannot find directory\(ies\): $bad_gitdir/,
"Got expected error: missing directory $bad_gitdir"
);
In all CPANtesters reports to date from Unix-like platorms, this code has worked. There's only one CPANtester submitting reports from Windows (in this case, Strawberry Perl running Perl 5.22.1) and that reporter is showing this test failure:
Unterminated \g... pattern in regex; marked by <-- HERE in m/Cannot find directory\(ies\): \home\jkeenan\g <-- HERE itwork\mist-compare/ at t/002-new.t line 38.I'm very puzzled by this (and I don't have a Windows box on which to debug this). The test code is clearly using m// as regex pattern delimiters, so I don't understand why, in this environment, \g is somehow being treated as if it were intended to be the end of the pattern.
Thoughts? Work-arounds?
Thank you very much.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unterminated \g... pattern in regex behaving badly on Windows
by Eily (Monsignor) on Nov 16, 2016 at 13:26 UTC | |
by Monk::Thomas (Friar) on Nov 16, 2016 at 13:46 UTC | |
by jkeenan1 (Deacon) on Nov 16, 2016 at 15:27 UTC | |
by jkeenan1 (Deacon) on Nov 16, 2016 at 15:17 UTC | |
by AnomalousMonk (Archbishop) on Nov 16, 2016 at 15:50 UTC | |
|
Re: Unterminated \g... pattern in regex behaving badly on Windows
by Corion (Patriarch) on Nov 16, 2016 at 14:23 UTC | |
|
Re: Unterminated \g... pattern in regex behaving badly on Windows
by kennethk (Abbot) on Nov 16, 2016 at 16:17 UTC |