I am writing a Perl module that involves some very complicated regular expressions that are nearly impossible to debug without a tool to help me. I figured the Regexp::Debugger
module would be the perfect tool for the job, but it only seems to work in .pl
scripts and doesn't seem to work within a .pm
module.
For example, this works:
test.pl
use strict;
use warnings;
use Regexp::Debugger;
my $text = "text";
if ($text =~ /tex/) {
print "Match!";
}
And I get the expected debugging functionality.
But the second I introduce a Perl Module to the mix it no longer works:
test.pl
use strict;
use warnings;
use TestModule;
TestModule::func();
TestModule.pm
package TestModule;
use strict;
use warnings;
use Regexp::Debugger;
sub func {
my $text = "text";
if ($text =~ /tex/) {
print "Match!";
}
}
1;
Attempting to run this code gives the following error:
Can't use an undefined value as a HASH reference at Regexp/Debugger.pm line 160
Simply including Regexp::Debugger
in the "test.pl" file instead doesn't work either because it doesn't try to debug regexes within included modules.
How can I get this to work so I can debug the regexes within a module that I'm working on?
UPDATE:
A bug report has been filed, and a new version (v0.002001) is now available on CPAN that works as expected. :)