in reply to Extracting regex from string

Please see Re: Evaluating $1 construct in literal replacement expression to begin your journey.

Update: Or am I reading more into your question than you intend? Maybe just:

c:\@Work\Perl\monks>perl -wMstrict -le "my $string = 'hello $1'; ;; if ('good morning all' =~ /good morning (\w+)/) { my $evaled_string = eval qq{ qq{$string} }; print qq{>$evaled_string<}; } " >hello all<
See eval. ("After parsing a file and extracting the following line..." Note that using string eval in this way is a potentially dangerous operation.)


Give a man a fish:  <%-{-{-{-<