http://qs321.pair.com?node_id=632882

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

Dear Monks,
I am slowly trying to understand all the power you can weld with regular expressions. What I have is a string: "This is a test". I want to take all of the words within this string and find all the word pairs: "This is", "is a", "a test".
I came up with this solution:
my $s = 'This is a test'; #Create an array my @words; while ($s =~ /(\w+)(?=\s+(\w+))/g){ #Push each found word into an array push @words, [$1,$2]; }
Strictly for pedantic reasons, is there a better solution?
Thanks,
s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;