$ cat t.pl use strict; use warnings; my $str = "123. The quick brown fox - Jumps over the"; if ($str =~ /^ # start of line\/string (\d+) # capture one or more digits \.\s+ # a literal period followed by some space (.*) # some characters \s+-\s+ # some space, a hyphen and more space (.*) # more characters $ # end of the line or string /x) { # x means allow whitespace and comments in regex my ($num, $text1, $text2) = ($1, $2, $3); print "num=$num, text1=<$text1>, text2=<$text2>\n"; } else { print "No match!\n"; } $ perl t.pl num=123, text1=, text2=