How do I match across newlines in a perl regex?
问题 I'm trying to work out how to match across newlines with perl (from the shell). following: (echo a b c d e; echo f g h i j; echo l m n o p) | perl -pe 's/(c.*)/[$1]/' I get this: a b [c d e] f g h i j l m n o p Which is what I expect. But when I place an /s at the end of my regex, I get this: a b [c d e ]f g h i j l m n o p What I expect and want it to print is this: a b [c d e f g h i j l m n o p ] Is the problem with my regex somehow, or my perl invocation flags? 回答1: -p loops over input