diff options
| author | fukachan <fukachan> | 2001-06-29 05:57:32 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-06-29 05:57:32 +0000 |
| commit | 98892cfb949baeaa4a3412351a178ff1c022f908 (patch) | |
| tree | e9ac7c60626c707d29806cb3df5ee22bb6557209 /fml/lib/IO | |
| parent | c9f8e684bdb41ac67be448162863a23df9507b4a (diff) | |
| download | fml8-98892cfb949baeaa4a3412351a178ff1c022f908.tar.gz fml8-98892cfb949baeaa4a3412351a178ff1c022f908.tar.bz2 fml8-98892cfb949baeaa4a3412351a178ff1c022f908.zip | |
modify IO::Adapter::find() method to accpet options "all"
my $addrs = $obj->find( $user , { all => 1 });
FML::Credential is modified to get all addresses which match /^$user/
once and search it within them.
1. get all entries match /^$user/ from $map.
2. try each address in the result matches $address to check.
3. is_same_address() conceals matching algorithm details.
Diffstat (limited to 'fml/lib/IO')
| -rw-r--r-- | fml/lib/IO/Adapter.pm | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/fml/lib/IO/Adapter.pm b/fml/lib/IO/Adapter.pm index 8f3dff30..43bc558e 100644 --- a/fml/lib/IO/Adapter.pm +++ b/fml/lib/IO/Adapter.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Adapter.pm,v 1.3 2001/06/09 10:55:49 fukachan Exp $ +# $FML: Adapter.pm,v 1.4 2001/06/09 14:27:39 fukachan Exp $ # package IO::Adapter; @@ -343,15 +343,20 @@ You can change the search behaviour by C<$args> (HASH REFERENCE). $args = { case_sensitive => 1, # case senssitive + all => 1, # get all entries matching $regexp as ARRAY REF }; +Normaly the result is given as a string. +If you specify C<all>, you get the result(s) as ARRAY REFERENCE. + =cut sub find { my ($self, $regexp, $args) = @_; my $case_sensitive = $args->{ case_sensitive } ? 1 : 0; - my $x; + my $show_all = $args->{ all } ? 1 : 0; + my (@buf, $x); # forward the request to SUPER class if ($self->SUPER::can('_find')) { $self->_find($regexp, $args);} @@ -359,17 +364,23 @@ sub find # search regexp by reading the specified map. $self->open; while (defined ($x = $self->get_next_value())) { - if ($case_sensitive) { - last if $x =~ /$regexp/; + if ($show_all) { + push(@buf, $x) if $x =~ /$regexp/; } else { - last if $x =~ /$regexp/i; + if ($case_sensitive) { + last if $x =~ /$regexp/; + } + else { + last if $x =~ /$regexp/i; + } } } + $self->close; - $x; -} + $show_all ? \@buf : $x; +} # Descriptions: destructor |
