foreach my $rx (@rxs) { if (my @captures = $text =~ /$rx/) { # do something meaningful with the captures } }