diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-08-09 17:19:01 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-08-09 17:19:01 +0000 |
commit | c086774ae7078d1932884ab51b0c82fdf5ba721f (patch) | |
tree | f3e8e3affbf32c36ad9f76d70276f3daa3e7ccf2 /MDK | |
parent | 3737b5eae3e09983b0b64d8f78fce92463957c16 (diff) | |
download | perl-MDK-Common-c086774ae7078d1932884ab51b0c82fdf5ba721f.tar perl-MDK-Common-c086774ae7078d1932884ab51b0c82fdf5ba721f.tar.gz perl-MDK-Common-c086774ae7078d1932884ab51b0c82fdf5ba721f.tar.bz2 perl-MDK-Common-c086774ae7078d1932884ab51b0c82fdf5ba721f.tar.xz perl-MDK-Common-c086774ae7078d1932884ab51b0c82fdf5ba721f.zip |
- each_index added
- a few more checks in perl_checker
Diffstat (limited to 'MDK')
-rw-r--r-- | MDK/Common.pm.pl | 2 | ||||
-rw-r--r-- | MDK/Common/Func.pm | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/MDK/Common.pm.pl b/MDK/Common.pm.pl index 9c06b66..50c197e 100644 --- a/MDK/Common.pm.pl +++ b/MDK/Common.pm.pl @@ -70,7 +70,7 @@ use vars qw(@ISA @EXPORT $VERSION); #); # perl_checker: RE-EXPORT-ALL @EXPORT = map { @$_ } map { values %{'MDK::Common::' . $_ . 'EXPORT_TAGS'} } grep { /::$/ } keys %MDK::Common::; -$VERSION = "1.0.1"; +$VERSION = "1.0.2"; 1; EOF diff --git a/MDK/Common/Func.pm b/MDK/Common/Func.pm index fb7157f..04a2402 100644 --- a/MDK/Common/Func.pm +++ b/MDK/Common/Func.pm @@ -59,6 +59,14 @@ just like C<map>, but set C<$::i> to the current index in the list: gives "0 a", "1 b" +=item each_index { CODE } LIST + +just like C<map_index>, but doesn't return anything + + each_index { print "$::i $_\n" } "a", "b" + +prints "0 a", "1 b" + =item grep_index { CODE } LIST just like C<grep>, but set C<$::i> to the current index in the list: @@ -133,7 +141,7 @@ use MDK::Common::Math; use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK); @ISA = qw(Exporter); -@EXPORT_OK = qw(may_apply if_ if__ fold_left mapn mapn_ map_index grep_index find_index map_each grep_each before_leaving catch_cdie cdie); +@EXPORT_OK = qw(may_apply if_ if__ fold_left mapn mapn_ map_index each_index grep_index find_index map_each grep_each before_leaving catch_cdie cdie); %EXPORT_TAGS = (all => [ @EXPORT_OK ]); @@ -183,6 +191,14 @@ sub map_index(&@) { my @v; local $::i = 0; map { @v = &$f($::i); $::i++; @v } @_; } +sub each_index(&@) { + my $f = shift; + my @v; local $::i = 0; + foreach (@_) { + &$f($::i); + $::i++; + } +} sub grep_index(&@) { my $f = shift; my $v; local $::i = 0; |