diff options
| author | fukachan <fukachan> | 2001-04-02 04:05:04 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-04-02 04:05:04 +0000 |
| commit | 80f59426231bc58a2f743885a92aa0a889db79e8 (patch) | |
| tree | 3d999f35fdf925d4a15b42869f7f81a5eb1944a9 /fml/lib | |
| parent | d7cd20ba3d62ddded24745e73780679d717534b7 (diff) | |
| download | fml8-80f59426231bc58a2f743885a92aa0a889db79e8.tar.gz fml8-80f59426231bc58a2f743885a92aa0a889db79e8.tar.bz2 fml8-80f59426231bc58a2f743885a92aa0a889db79e8.zip | |
enhance trap pattern
pick up all files in ~/.tsch/
Diffstat (limited to 'fml/lib')
| -rw-r--r-- | fml/lib/TinyScheduler.pm | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/fml/lib/TinyScheduler.pm b/fml/lib/TinyScheduler.pm index 7f197236..79686358 100644 --- a/fml/lib/TinyScheduler.pm +++ b/fml/lib/TinyScheduler.pm @@ -5,7 +5,7 @@ # redistribute it and/or modify it under the same terms as Perl itself. # # $Id$ -# $FML$ +# $FML: TinyScheduler.pm,v 1.2 2001/04/01 23:32:04 fukachan Exp $ # package TinyScheduler; @@ -83,14 +83,16 @@ sub parse $month = $args->{ month } || ($month + 1); # schedule file - my $data_file = $args->{ schedule_file } || $self->{ _schedule_file }; + my $data_dir = $args->{ schedule_dir } || $self->{ _schedule_dir }; # pattern to match - my @pat; - $pat[0] = sprintf("^%04d%02d(\\d{1,2})\\s+(.*)", $year, $month); - $pat[1] = sprintf("^%04d/%02d/(\\d{1,2})\\s+(.*)", $year, $month); - $pat[2] = sprintf("^%02d(\\d{1,2})\\s+(.*)", $month); - $pat[3] = sprintf("^%02d/(\\d{1,2})\\s+(.*)", $month); + my @pat = ( + sprintf("^%04d%02d(\\d{1,2})\\s+(.*)", $year, $month), + sprintf("^%04d/%02d/(\\d{1,2})\\s+(.*)", $year, $month), + sprintf("^%04d/%d/(\\d{1,2})\\s+(.*)", $year, $month), + sprintf("^%02d(\\d{1,2})\\s+(.*)", $month), + sprintf("^%02d/(\\d{1,2})\\s+(.*)", $month), + ); # use HTML::CalendarMonthSimple; @@ -104,23 +106,33 @@ sub parse croak("cannot get object"); } - $cal->width('50%'); + $cal->width('70%'); $cal->border(10); $cal->header(sprintf("%04d/%02d %s", $year, $month, "schedule")); $cal->bgcolor('pink'); - if (-f $data_file) { + if (-d $data_dir) { use FileHandle; - my $fh = new FileHandle $data_file; - while (<$fh>) { - for my $pat (@pat) { - if (/$pat(.*)/) { - $self->_parse($1, $2); + use DirHandle; + my $dh = new DirHandle $data_dir; + + if (defined $dh) { + while (defined($_ = $dh->read)) { + next if $_ =~ /~$/; + + my $fh = new FileHandle "$data_dir/$_"; + + while (<$fh>) { + for my $pat (@pat) { + if (/$pat(.*)/) { + $self->_parse($1, $2); + } + } } + close($fh); } } - close($fh); } } |
