Server IP : 103.119.228.120 / Your IP : 18.227.52.248 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/local/ssl/local/ssl/local/share/perl5/Set/ |
Upload File : |
# Copyright 2001 Abhijit Menon-Sen <ams@toroid.org> 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<crontab(5)>. A few extensions to the standard syntax are described below. =over 4 =item < and > <N selects the elements smaller than N from the entire range, and adds them to the set. >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<crontab(5)> =head1 AUTHOR Abhijit Menon-Sen <ams@toroid.org> Copyright 2001 Abhijit Menon-Sen <ams@toroid.org> This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.