summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-07-17 12:08:46 +0000
committerfukachan <fukachan>2002-07-17 12:08:46 +0000
commit819011b7696e4f152b608b75a32a362d362edd5e (patch)
treeeadf271dc047c4a285a259fa4825c868a321fa80
parentaa2c2279017d3f4440d5fca4ae2c06e09cffb94c (diff)
downloadfml8-819011b7696e4f152b608b75a32a362d362edd5e.tar.gz
fml8-819011b7696e4f152b608b75a32a362d362edd5e.tar.bz2
fml8-819011b7696e4f152b608b75a32a362d362edd5e.zip
add debug
define new() bug fix first:\d+ handle a,b,c pattern
-rw-r--r--fml/lib/Mail/Message/MH.pm44
1 files changed, 42 insertions, 2 deletions
diff --git a/fml/lib/Mail/Message/MH.pm b/fml/lib/Mail/Message/MH.pm
index 8d784d37..e051ae81 100644
--- a/fml/lib/Mail/Message/MH.pm
+++ b/fml/lib/Mail/Message/MH.pm
@@ -2,10 +2,11 @@
#
# Copyright (C) 2001,2002 Ken'ichi Fukamachi
#
-# $FML: MH.pm,v 1.5 2002/05/19 07:47:05 fukachan Exp $
+# $FML: MH.pm,v 1.6 2002/07/02 12:54:44 fukachan Exp $
#
package Mail::Message::MH;
+use strict;
=head1 NAME
@@ -36,6 +37,19 @@ return ARRAY_REF of numbers specified by the following format:
=cut
+# Descriptions: usual constructor
+# Arguments: OBJ($self) HASH_REF($args)
+# Side Effects: none
+# Return Value: OBJ
+sub new
+{
+ my ($self, $args) = @_;
+ my ($type) = ref($self) || $self;
+ my $me = {};
+ return bless $me, $type;
+}
+
+
# Descriptions: expand MH style expression to list of numbers
# Arguments: OBJ($self) STR($str) NUM($min) NUM($max)
# Side Effects: none
@@ -47,6 +61,14 @@ sub expand
unless (defined $min) { $min = 1;}
+ if ($str =~ /,/o) {
+ for my $s (split(/,/, $str)) {
+ my $ra0 = $self->expand($s, $min, $max);
+ for my $element (@$ra0) { push(@$ra, $element);}
+ }
+ return $ra;
+ }
+
if ($str eq 'all') {
unless (defined $max) { return undef;}
return _expand_range($min, $max);
@@ -75,7 +97,7 @@ sub expand
return [ $max ];
}
elsif ($str =~ /^first:(\d+)$/) {
- return _expand_range($min, $min + $1);
+ return _expand_range($min, $min + $1 - 1);
}
elsif ($str =~ /^last:(\d+)$/) {
unless (defined $max) { return undef;}
@@ -101,6 +123,24 @@ sub _expand_range
}
+if ($0 eq __FILE__) {
+ my $mh = new Mail::Message::MH;
+ for (qw(1,2,3
+ 1,10,last:20
+ 100
+ 100-110
+ first-110
+ 190-last
+ first first:10
+ last last:10
+ )) {
+ print "\n[$_] => ";
+ my $a = $mh->expand($_, 1, 200);
+ print "@$a\n";
+ }
+}
+
+
=head1 AUTHOR
Ken'ichi Fukamachi