in reply to Regexp matching words, not doing what I expect
If you have some strange compulsion not to use a module, you should still consider ditching the regex -- split the string into an array of words and use a for loop to output your word pairs:
(updated to fix bone-headed error in for loop)my @words = split " ", $text; print "$words[$_-1] $words[$_]\n" for ( 1 .. $#words );
|
|---|