• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Parse/H15-Dec-2009-17151

t/H15-Dec-2009-4741

Build.PLH A D15-Dec-2009292 1212

ChangesH A D15-Dec-2009140 97

LICENSEH A D14-Dec-20091.5 KiB2923

MANIFESTH A D15-Dec-2009147 1111

MANIFEST.SKIPH A D14-Dec-2009835 4830

META.ymlH A D15-Dec-2009491 2221

Makefile.PLH A D15-Dec-20091.2 KiB3524

READMEH A D14-Dec-20093 KiB9063

examples.plH A D15-Dec-2009160 74

README

1NAME
2    Parse::Range - Parse text range definitions
3
4SYNOPSIS
5      use Parse::Range qw(parse_range);
6
7      my @range = parse_range('1,3,5-7');
8      # @range = qw(1 3 5 6 7);
9
10      @range = parse_range('1-7,^2,^4');
11      # @range = qw(1 3 5 6 7);
12
13      @range = parse_range('1-7,^(2,4)');
14      # @range = qw(1 3 5 6 7);
15
16DESCRIPTION
17    This module parses range definitions and returns an array of individual
18    numbers.
19
20    It is intended to be used in command line applications where the user
21    should be able to select one or more options from a list or in any other
22    application where such a situation occurs.
23
24FUNCTIONS
25    By default no functions are exported.
26
27  parse_range
28    The one and only function this module provides. It accepts one or more
29    strings which are concatenated by a comma. Ranges, blocks and numbers
30    are expected to be seperated by comma.
31
32    Now the parsing takes place. Strings can be nested to any depth using
33    parentheses. Not matching parentheses are being repaired if possible.
34    Ranges can be expressed using the minus sign `-'. Use `^' to exclude
35    numbers or ranges from the current range. Negative numbers are expressed
36    using the minus sign. This is a valid expression `-4--2' which will
37    result in an array from minus four to minus two. `(-4)-(-2)' works as
38    well. The string is parsed from left to right.
39
40EXAMPLES
41      parse_range('1-7,^(2,4)');
42
43    This will first add the numbers from one to seven to the range and then
44    exclude the numbers two and 4. The result is `1 3 5 6 7'.
45
46      parse_range('^(2,4),1-7');
47
48     This is the same example as above except that it is the other way round. The exception of two and four
49     is a noop in this case because there is no range from which to exclude the numbers. The result is
50     therefore C<1 2 3 4 5 6 7>.
51
52       parse_range('1-9,^(5-9,^(8-9))');
53
54     This is a more advanced example. From a range from one to nine we exclude a block which consists
55     of a range from five to nine from which eight and nine are excluded.
56     The result is C<1 2 3 4 8 9>.
57
58AUTHOR
59    Moritz Onken, `<onken at netcubed.de>'
60
61BUGS
62    Please report any bugs or feature requests to `bug-Parse-Range at
63    rt.cpan.org', or through the web interface at
64    http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Parse-Range. I will be
65    notified, and then you'll automatically be notified of progress on your
66    bug as I make changes.
67
68SUPPORT
69    You can find documentation for this module with the perldoc command.
70
71        perldoc Parse::Range
72
73    You can also look for information at:
74
75    * RT: CPAN's request tracker
76        http://rt.cpan.org/NoAuth/Bugs.html?Dist=Parse-Range
77
78    * AnnoCPAN: Annotated CPAN documentation
79        http://annocpan.org/dist/Parse-Range
80
81    * CPAN Ratings
82        http://cpanratings.perl.org/d/Parse-Range
83
84    * Search CPAN
85        http://search.cpan.org/dist/Parse-Range/
86
87COPYRIGHT & LICENSE
88    Copyright 2009 Moritz Onken, all rights reserved.
89
90