in reply to Regex Word Pairs

Depends what you call better:

use strict; use warnings; my $s = 'This is a test'; my @pairs = $s =~ /(?=(\w+ \s+ \w+))\w+ \s+/gx; print join "\n", @pairs;

Prints:

This is is a a test

Update: or if you want @pairs as an AoA:

... my @pairs = map [split], $s =~ /(?=(\w+ \s+ \w+))\w+ \s+/gx; print "@$_\n" for @pairs;

prints:

This is is a a test

DWIM is Perl's answer to Gödel