in reply to surprised to find cannot assign s/../../ to a variable

Going back to your original question;
You can do this:
$a='aa'; $b='s/a/b/'; eval '$a =~ '.$b;

That means you can write:
my $namematch = $options{r} // 's/\.[^.]+$/+/r'; my @name; eval '@name = $file =~ '.$namematch;

But you're basically just having Perl write Perl for you. This may be what you want.
SANITIZE YOUR INPUT. The value in $options{r} could be used for injection.

HTH.

Replies are listed 'Best First'.
Re^2: surprised to find cannot assign s/../../ to a variable
by LanX (Saint) on Jul 09, 2024 at 14:43 UTC
Re^2: surprised to find cannot assign s/../../ to a variable
by vincentaxhe (Scribe) on Jul 09, 2024 at 04:05 UTC
    yeah, this is the best workaround