diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2006-11-24 15:54:34 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2006-11-24 15:54:34 +0000 |
commit | 4f3d92adb97d089521b4e62346d9034bf292f2bd (patch) | |
tree | e1563ed4aac4c93ff80b0ae5d6b0eb8a2d8020a9 /urpm/util.pm | |
parent | d42ad95a12aba5f2ca9ef783d904ea731e0a5982 (diff) | |
download | urpmi-4f3d92adb97d089521b4e62346d9034bf292f2bd.tar urpmi-4f3d92adb97d089521b4e62346d9034bf292f2bd.tar.gz urpmi-4f3d92adb97d089521b4e62346d9034bf292f2bd.tar.bz2 urpmi-4f3d92adb97d089521b4e62346d9034bf292f2bd.tar.xz urpmi-4f3d92adb97d089521b4e62346d9034bf292f2bd.zip |
add partition (from MDK::Common)
Diffstat (limited to 'urpm/util.pm')
-rw-r--r-- | urpm/util.pm | 10 |
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 } |