質問があります。

{
$str1 =~ /()()()/;
test("ほげ", $1, $2, $3);
} {
$str2 =~ /()()()/;
test("ふが", $1, $2, $3);
}

sub test {
$name = shift;
($hash{$name}{value1}, $hash{$name}{value2}, $hash{$name}{value4}) = @_;

{
$hash{$name}{value2} =~ /()/;
$hash{$name}{value3} = $1 ? $1 : 0;
} {
$hash{$name}{value4} =~ /()/;
$hash{$name}{value5} = $1 ? $1 : 0;
}
}

こういう処理をしたいんですが、このままだと呼び出し元の
$1がサブルーチン内でも有効であって期待通りの動きをしません。
ですので下の用に書き直しましたが、もっと簡潔に書けませんか?

続く