http://www.perlmonks.org?node_id=1101663


in reply to Turning on regexp debugging at runtime

As of 5.9.5 the directive use re 'debug'; is lexically scoped, so you can do something like:

my $re1 = qr/foo|bar/; { use re 'debug'; my $re2 = qr/quz|baz/; { no re 'debug'; my $re3 = qr/hello|world/; } }

And you'll only get debugging info for the scope where the directive is on.

See 'debug' in re and the pages it links to for more details. As you can see in that documentation, you can also use use re qw(Debug EXECUTE); to get only the debug output related to the run-time phase.