I am trying to debug a few regular expressions using:
perl -Mre=debug file.pl
The file.pl script has many regular expression. Some of them are repeated. Using the above syntax, all the regexes in file.pl are being debugged.
Is there a way to tell Perl to debug only a particular regex in a script?
I am familiar with the YAPE::Regex module, but that is not what I require. So please don’t suggest to use that.
A temporary(one-time-only) breakpoint can be set with the use of c-command by supplying a line number: DB<15> c 12 main::(debugtest:12): &readsubdirs($vardir); The argument 12 specified with the c-command tells the debugger to set a temporary breakpoint at line 12 and then continue execution.
Open a Perl source file, click "Run -> Start Debugging" or hit F5 and observe there is no error as before. Now explore all VSCocde IDE functions working nicely with Perl!
As with many other pragmas, you can use no
to cancel previous use
.
use re 'debug';
$str=~/\d{3}/;
no re 'debug';
$str=~/\d{3}/;
As of 5.9.5 the directive use re 'debug' and its equivalents are lexically scoped, as the other directives are.
Use:
{
use re 'debug';
# Debugged regexp here.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With