summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--urpm/util.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/urpm/util.pm b/urpm/util.pm
index 58922349..77ee415c 100644
--- a/urpm/util.pm
+++ b/urpm/util.pm
@@ -11,6 +11,7 @@ our @EXPORT = qw(quotespace unquotespace
untaint
copy_and_own
same_size_and_mtime
+ partition
difference2 member file_size cat_ dirname basename
);
@@ -115,6 +116,15 @@ sub same_size_and_mtime {
$sstat[7] == $lstat[7] && $sstat[9] == $lstat[9];
}
+sub partition(&@) {
+ my $f = shift;
+ my (@a, @b);
+ foreach (@_) {
+ $f->($_) ? push(@a, $_) : push(@b, $_);
+ }
+ \@a, \@b;
+}
+
sub difference2 { my %l; @l{@{$_[1]}} = (); grep { !exists $l{$_} } @{$_[0]} }
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 }