it doesn't recognise regular Real numbers like -2, -5

It does, here's a way you can test that (see e.g. How to ask better questions using Test::More and sample data):

use warnings; use strict; use Test::More; use Regexp::Common qw/number/; like "-2", qr/^$RE{num}{real}$/; like "-5", qr/^$RE{num}{real}$/; like " -5", qr/^$RE{num}{real}$/; done_testing; __END__ ok 1 ok 2 not ok 3 # Failed test at ... 1..3 # Looks like you failed 1 test of 3.

As you can see, the problem isn't that it doesn't match integers, it's the whitespace at the beginning of the line. Try changing

next if /^($RE{num}{real})/ && $1 > $limit; next if /^(\s\s-\d)/ && $1 > $limit;

to

next if /^\s*($RE{num}{real})/ && $1 > $limit;

Where \s* means "zero or more whitespace characters" (perlretut).


In reply to Re^11: Easiest way to filter a file based on user input by haukex
in thread Easiest way to filter a file based on user input by Peter Keystrokes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.