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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |