in reply to Re^2: Reliably parsing an integer
in thread Reliably parsing an integer
How are these regular expressions going to help? ... How is a regular expression going to help me accept 4294967295 ... but not 4294967296 ...? Regexes can help validate number formats, but not, in general, ranges. (It's quite often possible to construct a regex to discriminate a number range, but this is usually more of an academic exercise than a practical solution. Common exceptions are for decimal octet and year/month/day ranges.)To validate number formats, use Regexp::Common::number.[emphasis added]
... command-line option --resume-from-line ...
This quote from the OP suggests the user is to enter a simple line number of a file. Are you really dealing with source/data/whatever files of more than 4,000,000,000 (or 18,446,744,073,709,551,615 or, God help us all, 99,999,999,999,999,999,999) lines? If not, what do you care if your Perl is UINT32_MAX or UINT64_MAX? Why not just use a validation test something like
$n !~ /\D/ && $n < 4_000_000_000
(or some more reasonable upper limit) and be done with it?
Or is your question intended to address a more general case?
Give a man a fish: <%-{-{-{-<
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Reliably parsing an integer (updated)
by haukex (Archbishop) on Jun 29, 2020 at 21:35 UTC | |
Re^4: Reliably parsing an integer
by rdiez (Acolyte) on Jun 29, 2020 at 19:58 UTC | |
by hippo (Bishop) on Jun 29, 2020 at 21:30 UTC | |
by rdiez (Acolyte) on Jun 30, 2020 at 08:21 UTC | |
by haukex (Archbishop) on Jun 30, 2020 at 09:11 UTC | |
| |
by hippo (Bishop) on Jun 30, 2020 at 08:55 UTC | |
by rdiez (Acolyte) on Jun 30, 2020 at 10:34 UTC | |
|
In Section
Seekers of Perl Wisdom