in reply to Regular expression question

Assuming your text is well-formed, the following should work well as a more modular solution:
use strict; use warnings; my ($text, %percent); $text = 'Identities = 1529/1540 (99%), Gaps = 2/1540 (0%)'; $percent{$1} = $2 while $text =~ /(\w+) = \d+\/\d+ \((\d+)%\)/g; for (sort keys %percent) { print "$_ : $percent{$_}\n"; }
This way you can access any percentage by name.