perl regex not matching string with newline character \n

前端 未结 2 1978
孤城傲影
孤城傲影 2020-12-19 11:00

I\'m trying to use perl (v5.14.2) via a bash shell (GNU Bash-4.2) in Kubuntu (GNU/Linux) to search and replace a string that includes a newline character, but I\'m not succe

2条回答
  •  忘掉有多难
    2020-12-19 11:30

    The problem is that "-p" has already implicitly wrapped this loop around your "-e", and the "<>" is splitting the input into lines, so your regexp never gets a chance to see more than one line.

     LINE:
           while (<>) {
               ...             # your program goes here
           } continue {
               print or die "-p destination: $!\n";
           }
    

    See the perlrun manpage for more information.

提交回复
热议问题