#! /usr/local/bin/perl5.9.5 use v5.9.5; use Data::Dumper; my $re; $re = qr/ (?(DEFINE) (?The \s animal \s is: \s (?monkey|tiger|lion)) ) (?&phrase) /x; my $string = 'The animal is: tiger'; if ($string =~ $re) { say "Successfully matched."; print Dumper(\%+); print Dumper(\%-); }