Hi Monks,

I'm trying to design and implement a Perl module which takes a range list in string form and turns it into an object which represents the corresponding list of numbers and allows the calling code to access the list.

This is a bit of background:

An email server may be asked to operate on a number of messages at a time (e.g. 'DELETE' or 'FETCH'). Each message is identified by a number, and the messages a particular operation applies to is specified by a range-list. (e.g. DELETE 1, 4, 6-10)

A range-list is specified as a string of comma-separated elements (with optional whitespace). Each element is either a single number or a range (e.g. 10-20). A range is inclusive (i.e. it includes both end-points, so the range 10-12 includes messages 10, 11 and 12). Numbers may be specified multiple times, and ranges may overlap. The list may be in any particular order.

Examples:
1, 3, 5-7 specifies 1, 3, 5, 6, 7
1-5, 2, 4 specifies 1, 2, 3, 4, 5
1-3, 2-5 specified 1, 2, 3, 4, 5

I'm putting together my idea but any help would be greatly appreciated. Thanks,

In reply to Perl Module - take in a String, output object by MikeEndo

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.