in reply to Dynamically generating the replacement part of a substitution
Since you know the bits you want to replace already, it'd become something akin to:my @captures = ($input_token =~ /$regex/);
my $repl_index = 1; { print "attempt 1 "; my $str = "http://www.domain.com/"; my $regex = qr|http://(.*)\.(.*)\.(.*)|; my @captures = ($str =~ /$regex/i); print "yields: ", $captures[$repl_index], "\n"; }
|
|---|