diff options
| author | fukachan <fukachan> | 2003-02-01 04:34:33 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2003-02-01 04:34:33 +0000 |
| commit | 3d8e59aaca466c35d337d0e6ae1b79cda0ce2c08 (patch) | |
| tree | 3040208c0047e66febd1241f3f77764ace610440 /fml/lib/FML/Process | |
| parent | 8f7a56219c0989cf9494a9e01e7292037ee20b8b (diff) | |
| download | fml8-3d8e59aaca466c35d337d0e6ae1b79cda0ce2c08.tar.gz fml8-3d8e59aaca466c35d337d0e6ae1b79cda0ce2c08.tar.bz2 fml8-3d8e59aaca466c35d337d0e6ae1b79cda0ce2c08.zip | |
implement unique()
Diffstat (limited to 'fml/lib/FML/Process')
| -rw-r--r-- | fml/lib/FML/Process/Utils.pm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm index 9c74821c..6055e6ec 100644 --- a/fml/lib/FML/Process/Utils.pm +++ b/fml/lib/FML/Process/Utils.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: Utils.pm,v 1.55 2003/01/26 03:14:18 fukachan Exp $ +# $FML: Utils.pm,v 1.56 2003/01/29 13:27:32 fukachan Exp $ # package FML::Process::Utils; @@ -403,6 +403,36 @@ sub _cat } +=head2 unique( $array ) + +make components in $array unique. + +=cut + + +# Descriptions: make components in $array unique +# Arguments: OBJ($self) ARRAY_REF($array) +# Side Effects: none +# Return Value: ARRAY_REF +sub unique +{ + my ($self, $array) = @_; + my $x = []; + my $cache = {}; + + if (ref($array) eq 'ARRAY' && @$array) { + COMPONENT: + for my $k (@$array) { + next COMPONENT if $cache->{ $k }; + push(@$x, $k); + $cache->{ $k } = 1; + } + } + + return $x; +} + + =head1 METHODS for convenience =head2 fml_version() |
