From 4f3d92adb97d089521b4e62346d9034bf292f2bd Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 24 Nov 2006 15:54:34 +0000 Subject: add partition (from MDK::Common) --- urpm/util.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'urpm/util.pm') 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 } -- cgit v1.2.1