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


in reply to Re: Comparing Lines within a Word List
in thread Comparing Lines within a Word List

Let perl regex do the looping for you.

#!/usr/bin/perl -l use strict; use warnings; $_ = do{local $/; <DATA>}; /^((\w*) [rs] (\w*))$ # find a first word .* # skip non match lines ^(\2 [rs] \3)$ # second word same except rs (??{print "$1 $4"})/xms; # print and fail __DATA__ bare mare base case bust burt bent sat rat bat matter mattes pat