title: Search for lines that do not end with a given character
body: <p>I'm searching in a file for lines that do not end with a backslash (<code>\</code>), but they must begin with some text, so I've written:</p>
  
  <pre><code>if ( $cur_line =~ m{\A\s+(.+?)(?!\\)\z/xms ){
   ... # parentheses are only for testing
  }
  </code></pre>
  
  <p>But with the above <code>$1</code> always contains the whole line (without leading spaces) including the backslash at the end. Only the first occurrence of a line without a backslash at the end matches correctly. After this all the lines with trailing backslashes match. Why? What am I doing wrong?</p>
  
  <p>When I use:</p>
  
  <pre><code>if ( $cur_line =~ m{\A\s+[^\\]+(?!\\)\z/xms ){
   ...
  }
  </code></pre>
  
  <p>it works almost correctly however<code>$cur_line</code> then can contain a backslash.</p>
  
  <p>I've checked the following code:</p>
  
  <pre><code>if ( $cur_line !~ m{\\\z}xms ) {
  </code></pre>
  
  <p>amd it works perfectly. But I'm curious what is wrong with my negative lookahead.</p>