in reply to Last Letters

Assuming there are no other parens, you can do:

($number)=$string=~/\(([^)]*)\)/;

If that assumption is false, reverse it:

$string = reverse $string; ($number)=$string=~/\(([^)]*)\)/; $number = reverse $number;

Replies are listed 'Best First'.
Re: Re: Last Letters
by Dominus (Parson) on Nov 30, 2000 at 00:31 UTC
    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
      Oops, you're right. I tend to overuse reversing ever since I found it to be such a nice solution to the comma-fying a number FAQ.