Even if there are other parens, reversing the string twice
is a very weird way to get the data. Just use $
to anchor the match to the end of the string:
($number) = ($string =~ /\( (\d+) \) # number in parentheses
[^()]* $/x); # at the end of the string