On 01/07/2014 02:56 PM, David Precious wrote:
On Tue, 7 Jan 2014 13:35:39 -0600
Hal Wigoda <hal.wig...@gmail.com> wrote:
On Tue, Jan 7, 2014 at 1:28 PM, Rajeev Prasad <.ne...@yahoo.com>
wrote:
so i have this series of numbers:
[...]
there are two ranges in there: 349-396, 425-496

any hints as to how to write a perl code to represent the series of
numbers as a range?

(349..396,425..496);

The impression I got was that the OP wanted code to take that list of
numbers, and identify the ranges within.  I may be wrong, though.

regardless of the OP's intent, range manipulation is such a common and fairly easy thing, i was sure cpan had stuff for it. i recall some simple modules too but this one seems to do it all and more:

https://metacpan.org/pod/Range::Object

in a couple of quick calls the OP's list could be converted to a collapsed (2-4 style) string.

uri

--
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to