summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-07-21 16:59:18 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-07-21 16:59:18 +0000
commit5a5ec8d18c04f2077622bce50e7024e0749e4da8 (patch)
tree4449a44fc54d7f3e039045a476ecb14522ee5992 /perl-install/common.pm
parentdd40621fa1311c9bce97902e2db57f8b15fab449 (diff)
downloaddrakx-backup-do-not-use-5a5ec8d18c04f2077622bce50e7024e0749e4da8.tar
drakx-backup-do-not-use-5a5ec8d18c04f2077622bce50e7024e0749e4da8.tar.gz
drakx-backup-do-not-use-5a5ec8d18c04f2077622bce50e7024e0749e4da8.tar.bz2
drakx-backup-do-not-use-5a5ec8d18c04f2077622bce50e7024e0749e4da8.tar.xz
drakx-backup-do-not-use-5a5ec8d18c04f2077622bce50e7024e0749e4da8.zip
*** empty log message ***
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r--perl-install/common.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index c15aafdae..feec2e844 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -6,7 +6,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int
@ISA = qw(Exporter);
%EXPORT_TAGS = (
- common => [ qw(_ __ min max bool member divide is_empty_array_ref round_up round_down first top translate) ],
+ common => [ qw(_ __ min max bool member divide is_empty_array_ref set_new set_add round_up round_down first second top uniq translate) ],
file => [ qw(dirname basename all glob_ cat_ chop_ mode) ],
system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ crypt_) ],
constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE) ],
@@ -25,7 +25,9 @@ sub __ { $_[0] }
sub min { my $min = shift; grep { $_ < $min and $min = $_; } @_; $min }
sub max { my $max = shift; grep { $_ > $max and $max = $_; } @_; $max }
sub first { $_[0] }
+sub second { $_[1] }
sub top { $_[$#_] }
+sub uniq { my %l; @l{@_} = (); keys %l }
sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 }
sub dirname { @_ == 1 or die "usage: dirname <name>\n"; local $_ = shift; s|[^/]*/*\s*$||; s|(.)/*$|$1|; $_ || '.' }
sub basename { @_ == 1 or die "usage: basename <name>\n"; local $_ = shift; s|/*\s*$||; s|.*/||; $_ }
@@ -38,6 +40,9 @@ sub round_up { my ($i, $r) = @_; $i += $r - ($i + $r - 1) % $r - 1; }
sub round_down { my ($i, $r) = @_; $i -= $i % $r; }
sub is_empty_array_ref { my $a = shift; !defined $a || @$a == 0 }
+sub set_new(@) { my %l; @l{@_} = undef; { list => [ @_ ], hash => \%l } }
+sub set_add($@) { my $o = shift; foreach (@_) { exists $o->{hash}->{$_} and next; push @{$o->{list}}, $_; $o->{hash}->{$_} = undef } }
+
sub sync { syscall_('sync') }
sub gettimeofday { my $t = pack "LL"; syscall_('gettimeofday', $t, 0) or die "gettimeofday failed: $!\n"; unpack("LL", $t) }