perlquestion
Anonymous Monk
Hi Monks!<br><br>
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?<br>
<code>
#!/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";
</code>
<br> When I print $1, I am only getting "This".<br>
Thanks for looking!<br>
8