http://qs1969.pair.com?node_id=11135816

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

Trying to get the last word in a sentence and the rest in another variable, I guess the regular expression needs to start from right to left correct?
#!/usr/bin/perl use strict; use warnings; my list = "This is my list"; list =~ /(\w+)\s(\w+)/; my $last = $2; my $the_rest = $1 print $the_rest # "This is my" print $last # "list";

When I print $1, I am only getting "This".
Thanks for looking!