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

I see error in your code:

my @dat=[qw(foo bar)];

You are trying to assign @var the reference to an array (not an array). You should:

my @dat=qw(foo bar);

Please, don't forget to use warnings pragma. It helps with these kinds of mistakes.

Replies are listed 'Best First'.
Re^2: Can't do dereference when running code inserted inside regex
by LanX (Saint) on Jan 16, 2022 at 10:42 UTC
    Yes it looks strange, but that's what he wanted. Look at the dereference inside the loop.

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