in reply to Can't do dereference when running code inserted inside regex

Dave is right

And it's documented in perlre#(?{-code-}), right where it's supposed to be.

Inside a (?{...}) block, $_ refers to the string the regular expression is matching against. You can also use pos() to know what is the current position of matching within this string.

The solution is simple, use an explicit loop variable:

for my $d (@dat){ push (my @u, [$d->[0], $d->[1]]); ...

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Can't do dereference when running code inserted inside regex
by Anonymous Monk on Jan 17, 2022 at 04:38 UTC
    Dave, LanX are right.
    EXCELLENT ! Thanks billions.