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