in reply to Help with Regular Expression matching

my ($match) = grep defined, $string =~ /<(ab)>|(ab)/;
or use (?(condition)...), taken almost literally from perlre:
my ($quoted,$match) = $string =~ /(<)?(ab)(?(1)>)/x; # or: my $match = ($string =~ /(<)?(ab)(?(1)>)/)[1];