私は機能を持っています:
my $descr = 'Rand [Hi|Hello|Aloha] [Kate|Ann|Polly]';
print intrp($descr);
sub intrp($str)
{
my $str =~ s{
\[ ( [^\]]* ) \]
}{
my @choices = split /\|/, $1;
$choices[rand(@choices)]
}xeg;
return $str;
}
なぜ機能しないのですか?= \他の方法を試しましたが、役に立ちませんでした