in reply to Re: On error, how to show the regexp values? (tracing warnings)
in thread Tracing warnings: how to show the regexp values?
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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: On error, how to show the regexp values? (tracing warnings)
by LanX (Saint) on Jan 07, 2017 at 16:03 UTC | |
by Anonymous Monk on Jan 08, 2017 at 02:01 UTC | |
|
Re^3: On error, how to show the regexp values? (tracing warnings)
by nikolay (Beadle) on Jan 19, 2017 at 08:05 UTC | |
|
Re^3: On error, how to show the regexp values? (tracing warnings)
by nikolay (Beadle) on Jan 28, 2017 at 04:12 UTC | |
by AnomalousMonk (Archbishop) on Jan 28, 2017 at 12:35 UTC |