summaryrefslogtreecommitdiffstats
path: root/urpm/util.pm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm/util.pm')
-rw-r--r--urpm/util.pm4
1 files changed, 3 insertions, 1 deletions
diff --git a/urpm/util.pm b/urpm/util.pm
index c6d51ea4..0af9cc53 100644
--- a/urpm/util.pm
+++ b/urpm/util.pm
@@ -13,7 +13,8 @@ our @EXPORT = qw(min max quotespace unquotespace
same_size_and_mtime
partition put_in_hash uniq uniq_
begins_with
- difference2 member file_size cat_ cat_utf8 output_safe dirname basename
+ difference2 intersection member
+ file_size cat_ cat_utf8 output_safe dirname basename
);
(our $VERSION) = q($Revision$) =~ /(\d+)/;
@@ -137,6 +138,7 @@ sub begins_with {
sub put_in_hash { my ($a, $b) = @_; while (my ($k, $v) = each %{$b || {}}) { $a->{$k} = $v } $a }
sub uniq { my %l; $l{$_} = 1 foreach @_; grep { delete $l{$_} } @_ }
sub difference2 { my %l; @l{@{$_[1]}} = (); grep { !exists $l{$_} } @{$_[0]} }
+sub intersection { my (%l, @m); @l{@{shift @_}} = (); foreach (@_) { @m = grep { exists $l{$_} } @$_; %l = (); @l{@m} = () } keys %l }
sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 }
sub cat_ { my @l = map { my $F; open($F, '<', $_) ? <$F> : () } @_; wantarray() ? @l : join '', @l }
sub cat_utf8 { my @l = map { my $F; open($F, '<:utf8', $_) ? <$F> : () } @_; wantarray() ? @l : join '', @l }