The reason is that your anonymous sub first prints the string and returns the return value of print (usually 1 for successful printing). Then you print the content in the $html variable.
I would suggest that you re-define your embedded perl in such a way that it returns a string (just remove the print command in the embedded perl. Then the embedded perl section will be replaced by the resulting string which is what you want (I assume). Code could look like this:
use strict; use warnings; use 5.0080; my $html =<<'HTML'; <div> <p>Code</p> <?perl my $string = "Hello World"; "<b>$string</b>"; ?> </div> HTML $html =~ s/\<\?perl(.*?)\?\>/(sub{$1})->()/gisee; print $html;
In reply to Re: Eval in RegEx ...
by hdb
in thread Eval in RegEx ...
by thakares
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |