set-crontab-perl-1.03.orig/0000755000175000017500000000000011371260103014503 5ustar rackerackeset-crontab-perl-1.03.orig/Makefile.PL0000644000175000017500000000023511043712042016455 0ustar rackerackeuse ExtUtils::MakeMaker; WriteMakefile( NAME => 'Set::Crontab', VERSION_FROM => 'Crontab.pm', ABSTRACT_FROM => 'Crontab.pm', ); set-crontab-perl-1.03.orig/README0000644000175000017500000000276311043712452015400 0ustar rackerackeNAME Set::Crontab - Expand crontab(5)-style integer lists SYNOPSIS $s = Set::Crontab->new("1-9/3,>15,>30,!23", [0..30]); if ($s->contains(3)) { ... } DESCRIPTION Set::Crontab parses crontab-style lists of integers and defines some utility functions to make it easier to deal with them. Syntax Numbers, ranges, *, and step values all work exactly as described in the crontab(5) manpage. A few extensions to the standard syntax are described below. < and > N does likewise for elements larger than N. ! !N excludes N from the set. It applies to the other specified range; otherwise it applies to the specified ranges (i.e. "!3" with a range of "1-10" corresponds to "1-2,4-10", but ">3,!7" in the same range means "4-6,8-10"). Functions new($spec, [@range]) Creates a new Set::Crontab object and returns a reference to it. contains($num) Returns true if `$num' exists in the set. list() Returns the expanded list corresponding to the set. The functions described above croak if they are called with incorrect arguments. SEE ALSO The crontab(5) manpage. AUTHOR Abhijit Menon-Sen Copyright 2001 Abhijit Menon-Sen This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. set-crontab-perl-1.03.orig/Changes0000644000175000017500000000061711371257522016015 0ustar rackeracke1.03 2010-05-08 * Return list elements in sorted order. 1.02 2008-07-30 * The 1.01 distribution tarball was broken; this is what it should have been. 1.01 2008-07-30 * Relicensed on request from the old Artistic License to "the same terms as Perl itself" (i.e. new Artistic/GPL). (No functional changes.) 1.00 2001-05-01 * First stable release. set-crontab-perl-1.03.orig/META.yml0000644000175000017500000000077111371260103015761 0ustar rackeracke--- #YAML:1.0 name: Set-Crontab version: 1.03 abstract: Expand crontab(5)-style integer lists author: [] license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: {} no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.56 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 set-crontab-perl-1.03.orig/test.pl0000644000175000017500000000163211371260043016024 0ustar rackerackeuse strict; use Test; use vars qw($loaded); BEGIN { plan tests => 11 } END { print "not ok 1\n" unless $loaded } use Set::Crontab; ok($loaded = 1); my $r = [0..10]; ok(Set::Crontab->new("1,2,3,4,5,6", $r)->contains(6)); ok(Set::Crontab->new("1-10", $r)->contains(5)); ok(Set::Crontab->new("1-2,3-4,5-6,7-8,9-10", $r)->contains(7)); ok(Set::Crontab->new("1-4,5-10", $r)->contains(7)); ok(Set::Crontab->new("*/3", $r)->contains(6)); my $s = Set::Crontab->new("!3", $r); ok(!$s->contains(3) && $s->contains(1)); $s = Set::Crontab->new(">3,<8", $r); ok(!$s->contains(2) && $s->contains(6)); $s = Set::Crontab->new(">3,<8,!6", $r); ok(!$s->contains(6) && $s->contains(7)); $s = Set::Crontab->new("*,!8", $r); ok(!$s->contains(8) && $s->contains(3)); $s = Set::Crontab->new("1,*/2,!4", $r); ok(!$s->contains(4) && $s->contains(2)); $s = Set::Crontab->new("45,15,30", [0..50]); ok(join("", $s->list()) eq "153045"); set-crontab-perl-1.03.orig/MANIFEST0000644000175000017500000000020611371260103015632 0ustar rackerackeChanges Crontab.pm Makefile.PL README test.pl MANIFEST META.yml Module meta-data (added by MakeMaker) set-crontab-perl-1.03.orig/Crontab.pm0000644000175000017500000000650011371260062016436 0ustar rackeracke# Copyright 2001 Abhijit Menon-Sen package Set::Crontab; use strict; use Carp; use vars qw( $VERSION ); $VERSION = '1.03'; sub _expand { my (@list, @and, @not); my ($self, $spec, $range) = @_; # 1,2-4,*/3,!13,>9,<15 foreach (split /,/, $spec) { my @pick; my $step = $1 if s#/(\d+)$##; # 0+"01" == 1 if (/^(\d+)$/) { push @pick, 0+$1; } elsif (/^\*$/) { push @pick, @$range; } elsif (/^(\d+)-(\d+)$/) { push @pick, 0+$1..0+$2; } elsif (/^!(\d+)$/) { push @not, "\$_ != 0+$1"; } elsif (/^([<>])(\d+)$/) { push @and, "\$_ $1 0+$2"; } if ($step) { my $i; @pick = grep { defined $_ if $i++ % $step == 0 } @pick; } push @list, @pick; } if (@and) { my $and = join q{ && }, @and; push @list, grep { defined $_ if eval $and } @$range; } if (@not) { my $not = join q{ && }, @not; @list = grep { defined $_ if eval $not } (@list ? @list : @$range); } @list = sort { $a <=> $b } @list; return \@list; } sub _initialise { my ($self, $spec, $range) = @_; return undef unless ref($self); croak "Usage: ".__PACKAGE__."->new(\$spec, [\@range])" unless defined $spec && ref($range) eq "ARRAY"; $self->{LIST} = $self->_expand($spec, $range); $self->{HASH} = {map {$_ => 1} @{$self->{LIST}}}; return $self; }; sub new { my $class = shift; my $self = bless {}, ref($class) || $class; return $self->_initialise(@_); } sub contains { my ($self, $num) = @_; croak "Usage: \$set->contains(\$num)" unless ref($self) && defined $num; return exists $self->{HASH}{$num}; } sub list { my $self = shift; croak "Usage: \$set->list()" unless ref($self); return @{$self->{LIST}}; } 1; __END__ =head1 NAME Set::Crontab - Expand crontab(5)-style integer lists =head1 SYNOPSIS $s = Set::Crontab->new("1-9/3,>15,>30,!23", [0..30]); if ($s->contains(3)) { ... } =head1 DESCRIPTION Set::Crontab parses crontab-style lists of integers and defines some utility functions to make it easier to deal with them. =head2 Syntax Numbers, ranges, *, and step values all work exactly as described in L. A few extensions to the standard syntax are described below. =over 4 =item < and > N does likewise for elements larger than N. =item ! !N excludes N from the set. It applies to the other specified range; otherwise it applies to the specified ranges (i.e. "!3" with a range of "1-10" corresponds to "1-2,4-10", but ">3,!7" in the same range means "4-6,8-10"). =back =head2 Functions =over 4 =item new($spec, [@range]) Creates a new Set::Crontab object and returns a reference to it. =item contains($num) Returns true if C<$num> exists in the set. =item list() Returns the expanded list corresponding to the set. Elements are in ascending order. =back The functions described above croak if they are called with incorrect arguments. =head1 SEE ALSO L =head1 AUTHOR Abhijit Menon-Sen Copyright 2001 Abhijit Menon-Sen This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.