echo"Walmart chief executive Douglas McMillon defendscompany's decision to invest billions in improving its stores and Internetshopping presence" | perl -nle ' $r = qr"((?:\b[\w'\'']+\b\s*){1,3})\s*McMillon\s*((?:\b[\w'\'']+\b\s*){1,3})"; /$r/ ; print "3 word before McMillon : $1" ; print "3 wordafter McMillon : $2" '