aboutsummaryrefslogtreecommitdiffstats
path: root/Perl
diff options
context:
space:
mode:
authorBas Zoetekouw <bas>2008-09-30 19:20:15 +0000
committerBas Zoetekouw <bas>2008-09-30 19:20:15 +0000
commitb8bbe054324844ae6cdfc1fcd64dc66bc7a1326c (patch)
treea9cb39b1caa3558bceb7793a5268e7c14da62221 /Perl
parent39d1699093c380c7664132a2f41bfac2f22b9011 (diff)
- Introduce Local::Util to contain useful utility functions.
- Copy uniq() from List::MoreUtils to Local::Util - Get rid of dependencies on List::MoreUtils in favour of Local::Util CVS version numbers check_desc_trans.pl: 1.6 -> 1.7 check_trans.pl: 1.70 -> 1.71 Perl/Local/Util.pm: INITIAL -> 1.1
Diffstat (limited to 'Perl')
-rw-r--r--Perl/Local/Util.pm66
1 files changed, 66 insertions, 0 deletions
diff --git a/Perl/Local/Util.pm b/Perl/Local/Util.pm
new file mode 100644
index 00000000000..87501fb6383
--- /dev/null
+++ b/Perl/Local/Util.pm
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+Local::Utils - generic utils for use in webwml script
+
+=head1 SYNOPSIS
+
+ use Local::Utils ':all';
+
+=head1 DESCRIPTION
+
+This module contains a few helper routines that are useful in the webwml
+scripts, and for which we don't want to add dependencies on external modules.
+
+=head1 METHODS
+
+=over 4
+
+=cut
+
+package Local::Util;
+
+use 5.008;
+
+use strict;
+use warnings;
+
+BEGIN {
+ use base qw( Exporter );
+
+ our $VERSION = sprintf "%d", q$Revision$ =~ /(\d+)/g;
+ our @EXPORT_OK = qw( uniq );
+ our %EXPORT_TAGS = ( 'all' => [@EXPORT_OK] );
+}
+
+
+=item uniq
+
+Returns a new list by stripping duplicate values in LIST. The order of elements
+in the returned list is the same as in LIST. In scalar context, returns the
+number of unique elements in LIST.
+
+Example use:
+
+ my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4
+ my $x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5
+
+
+This code was copied literally from List::MoreUtils.
+
+Copyright (C) 2004-2006 by Tassilo von Parseval <tassilo.von.parseval@rwth-aachen.de
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself, either Perl version 5.8.4 or, at your option,
+any later version of Perl 5 you may have available.
+
+=cut
+sub uniq (@)
+{
+ my %h;
+ map { $h{$_}++ == 0 ? $_ : () } @_;
+}
+
+42;
+
+__END__

© 2014-2024 Faster IT GmbH | imprint | privacy policy