my $str = 'The rabbits is $10 and the dogs are $20. The phone number is 555-1212.'; # updated: thanks to davido to point out the interpolation # of $10 and $20 in my double quoted string. I have changed # the double quote to single quote. my @capture = $str =~ /(rabbits|dogs|\d+-\d+)/g; print "$_\n" for @capture; #### use strict; use Data::Dumper; my $str = 'The rabbits is $10 and the dogs are $20. ' . 'The phone number is 555-1212, mobile number 0404-120021'; my $animal = "rabbit|dog"; my %prices = $str =~ m/((?:$animal)s?)\s(?:is|are)\s(\$\d+)/g; my @phone = $str =~ m/(\d+-\d+)/g; print Dumper(\%prices); print Dumper(\@phone); #### $VAR1 = { 'dogs' => '$20', 'rabbits' => '$10' }; $VAR1 = [ '555-1212', '0404-120021' ];