my $num=qr/(-?\d++\.?\d*?)/; ... unshift(@stack, [$2,$3,$4]) while $given =~ s/(.*)\((\S++) ++(-?\d++\.?\d*?) ++(-?\d++\.?\d*?)?\)/$1/;