#!perl -l print $_="the thing that that thing does"; /(\w+) that/ and printf '$&=%-20s $1=%-10s %s',$&,$1,$/; /($1) (\w+)/ and printf '$&=%-20s $1=%-10s $2=%-10s %s',$&,$1,$2,$/; /$1 (\w+) (\1)/ and printf '$&=%-20s $1=%-10s $2=%-10s %s',$&,$1,$2,$/; __END__ the thing that that thing does $&=thing that $1=thing $&=thing that $1=thing $2=that $&=thing that that $1=that $2=that