'Substitute the markdown italic to html using regex in Perl

To convert the markdown italic text $script into html, I've written this:

my $script = "*so what*";
my $res =~ s/\*(.)\*/$1/g;
print "<em>$1</em>\n";

The expected result is:

<em>so what</em>

but it gives:

<em></em>

How to make it give the expected result?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source