I can't say I recommend this, but a sort of minimal change would be:
my $patternreadfromfile = q{<h1 tag="@{[substr "$2",1,-1]}">@{[substr "$1",1,-1]}</h1>};
It is probably more comprehensible to do something like this:
my $patternreadfromfile= q{do_what_i_want( $1, $2 )}; sub do_what_i_want { my ($one, $two) = @_; for ( $one, $two ) { s/\A.(.*).\z/$1/; } return qq{<h1 tag="$one">$two</h1>}; } my $outpattern = $patternreadfromfile;
Of course, you'll want to replace my silly names with your own silly names. If you don't want your namespace polluted with this sub, you could make it an anonymous sub in a lexical that will go away when you're done with it. In that case, it looks like this:
my $doit = sub { my ($one, $two) = @_; for ( $one, $two ) { s/\A.(.*).\z/$1/; } return qq{<h1 tag="$one">$two</h1>}; }; my $patternreadfromfile= q{$doit->( $1, $2 )};
In reply to Re: Regexp::Common balanced curlies substitution
by kyle
in thread Regexp::Common balanced curlies substitution
by iaw4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |