Even outside the debugger, you can establish a warnings handler:
#!/usr/bin/perl
use warnings;
use strict;
my $sod='ip6 is used for...';
my $i=0;
my @baza_tek=qw( (?^u:ip(\d)) "internet_protocol-$1$2" );
{
local $SIG{__WARN__} = sub {
warn @_;
warn "\$baza_tek[$i] is '$baza_tek[$i]";
my $j = $i + 1;
warn "\$baza_tek[$j] is '$baza_tek[$j]";
};
$sod=~s#$baza_tek[$i]#$baza_tek[$i+1]#gee;
}
And the reason $2 is undefined is that your regular expression has only one capture group, (\d). | [reply] [d/l] [select] |
?
> Even outside the debugger, you can establish a warnings handler:
Yes, since "for debugging" doesn't mean "inside debugger"
> And the reason $2 is undefined
see Re: On error, how to show the regexp values? (?: doesn't capture)
> has only one capture group, (\d).
capture groups are unrelated to \d
The outer parens would capture without the colon :
| [reply] [d/l] [select] |
>> has only one capture group, (\d).
> capture groups are unrelated to \d
Capture groups in general are unrelated to \d, but nonetheless the lone capture group in the regexp is (\d).
> The outer parens would capture without the colon :
Also correct. But in fact the outer parens do have the colon, so they do not capture.
| [reply] [d/l] |
| [reply] |
But farther testing, on real data (that is much and is taken from different sources) did show, that the kind of exception, shows not the culprit at the time the error occurs. -- Like, if we have 1 000 patterns, and pattern #345 contains the error in focus, then the exception will show, say, pattern #378 -- back or forth in the row of patterns from the problem pattern, i do not know, having brought that exapmple just for better illustration of what i mean.
Personally, i think that the PERL mechanism for error handling, simply is late, and except it can be fixed, i think additional peace of code needs to be written like above have said -- that checks every pattern regexp, but, again, then we will get a lot matches, among whom will be the culprit.
So, before getting that mess of results, in order to make things done, i ask here for "wisdom" -- as it is kept saying here. ;-)
| [reply] |
Of course, you don't give a code example showing the problem(s) you are encountering. Even so, here's some code that might be food for thought, incorporating a number of guesses on my part.
File templated_substitute_2.pl:
Output:
Note that the faulty regex example
# [ '(?^u:BADREGEX+++)' => 'bad regex - match fails' ],
will appear for every line processed if you enable it; it's just there to show the effect.
Give a man a fish: <%-{-{-{-<
| [reply] [d/l] [select] |