if(m[/\w+/foo]) { s[.* /(\w+) /foo \z]($1)x; ... } #### print m{ /(\w+) /foo\z }x, "\n" for @FILES;