Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Lets warm up by refining and correcting some of your code:</p> <pre><code># If these are all numbers, do a numerical sort: &lt;=&gt; not cmp my @atoms = ( sort { $b &lt;=&gt; $a } keys %{$atome} ); my $natoms = scalar @atoms; </code></pre> <p>No need to loop through the keys, you can insert them into the array right away. You can also sort them right away, and if they are numbers, the sort must be numerical, otherwise you will get a sort like: 1, 11, 111, 2, 22, 222, ...</p> <p><code>$natoms</code> can be assigned directly by the count of values in <code>@atoms</code>.</p> <hr> <pre><code>while(&lt;IN_LIG&gt;) { last unless $natoms; my $key = (split)[0]; # split splits on whitespace and $_ by default $natoms-- if ($key == $atoms[$natoms - 1]); } </code></pre> <p>I'm not quite sure what you are doing here, and if it is the best way, but this code should work, whereas your regex would not. Inside a regex, <code>[]</code> are meta characters. Split by default splits <code>$_</code> on whitespace, so you need not be explicit about that. This split will also definitely remove all whitespace. Your empty field is most likely an empty string, '', and not a space ' '.</p> <p>The best way to compare two numbers is not by a regex, but with the equality operator <code>==</code>.</p> <p>Your empty field should be gone by splitting on whitespace. The default for <code>split</code> is <code>split ' '</code>.</p> <p>Also, if you are not already doing it, you should use:</p> <pre><code>use strict; use warnings; </code></pre> <p>It will save you a lot of headaches.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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