Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li><p>Your first snippet doesn't &laquo;kill just about anything with the word " at " in it.&raquo;. <code>at</code> has to be the second last word for it do anything.</p></li> <li><p>I think your two snippets (forward and reverse) are 100% equivalent (except that the second doesn't support a trailing newline, so it's probably never going to match).</p></li> <li><p>The pattern</p> <pre><code>/\s+ at \s+ \S+ (?:\s+ line \s+ \d+)?$/x </code></pre> <p>isn't going to match</p> <pre><code>$ perl -e'(eval "sub { die }")-&gt;()' Died at (eval 1) line 1. </code></pre></li> <li><p>The pattern</p> <pre><code>/\s+ at \s+ \S+ (?:\s+ line \s+ \d+)?$/x </code></pre> <p>isn't going to match</p> <pre><code>$ echo foo | perl -e'&lt;STDIN&gt;; die;' Died at -e line 1, &lt;STDIN&gt; line 1. </code></pre></li> <li><p>I don't think Perl will ever add a file name without adding a number.</p> <p>If the line number is optional, then it's inevitable that you'll match the last two words of "Dinner is at nine." unless you start employing heuristics.</p></li> </ol> <hr> <p>Looking at the source code, this is what <code>die</code> can append:</p> <pre><code>Adds: " at %s line %"IVdf Sometimes followed by: ", &lt;%"SVf"&gt; line %"IVdf or by: ", &lt;%"SVf"&gt; chunk %"IVdf Sometimes followed by: " during global destruction" Always followed by: ".\n" </code></pre> <p>That gives us:</p> <pre><code>s/ (?&amp;BASE) (?&amp;IO_CLAUSE)? (?&amp;GLOBAL_DESTR)? \.?\n\z (?(DEFINE) (?&lt;BASE&gt; [ ] at [ ] (?&amp;FILE_NAME) [ ] line [ ] [0-9]+ ) (?&lt;IO_CLAUSE&gt; , [ ] &lt;(?&amp;HANDLE_NAME)&gt; [ ] (?:line|chunk) [ ] [0-9]+ ) (?&lt;GLOBAL_DESTR&gt; [ ]during[ ]global[ ]destruction ) # Heuristics: (?&lt;FILE_NAME&gt; \S+ | \(eval[ ][0-9]+\) ) (?&lt;HANDLE_NAME&gt; \w+ ) ) //x </code></pre> <p>That's as specific as it can be.</p> <p>(Note: Carp sometimes forgets the trailing "<code>.</code>", from what I hear.)</p> <p>(Note: Perl uses single spaces, so <code>[ ]</code> is more precise than <code>\s+</code>.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload