As using the string form of eval with untrusted input is a considerable security risk, and your markdown can easily contain double-quotes which break your code, maybe you are interested in using a templating system or simply applying this very small, very simple templating system? It allows you to restrict what variables get interpolated, and it prevents execution of arbitrary code:
sub interpolate { my ($text, %vars) = @_; $text =~ s!\$(\w+)|\$\{(\w+)\}! my $name = $1 || $2; exists $vars{ $name } ? $vars{ $name } : '$' . $name !ge; return $text }; print interpolate( 'Hello $user, this is $var1. We also use the unknown variable $foo +.', var1 => 'The value of var1', user => 'Je55eah', # ... );
In reply to Re^2: my $scope as the default for variables
by Corion
in thread Please help me print this hash.
by Je55eah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |