summaryrefslogtreecommitdiffstats
path: root/TOOLS/lib/Parse/Matroska/Utils.pm
diff options
context:
space:
mode:
authorKovensky <diogomfranco@gmail.com>2012-11-07 11:49:44 -0300
committerwm4 <wm4@nowhere>2012-11-08 00:28:59 +0100
commitfae73079310eef9dce9737f2e37ff4b80c8830ee (patch)
tree4a9c7d9fbc398b237808283df39562e55077a225 /TOOLS/lib/Parse/Matroska/Utils.pm
parent58f821e096392e27994102f6de6f8f76c63e38e1 (diff)
downloadmpv-fae73079310eef9dce9737f2e37ff4b80c8830ee.tar.bz2
mpv-fae73079310eef9dce9737f2e37ff4b80c8830ee.tar.xz
Port several python scripts to Perl
file2string.pl and vdpau_functions.pl are direct ports. matroska.py was reimplemented as the Parse::Matroska module in CPAN, and matroska.pl was made a client of Parse::Matroska. A copy of Parse::Matroska is included in TOOLS/lib, and matroska.pl looks there first when trying to load the module. osxbundle.py was not ported since I have no means to verify it. Python is always available on OSX though, so there is no harm in removing the check for it on configure.
Diffstat (limited to 'TOOLS/lib/Parse/Matroska/Utils.pm')
-rw-r--r--TOOLS/lib/Parse/Matroska/Utils.pm37
1 files changed, 37 insertions, 0 deletions
diff --git a/TOOLS/lib/Parse/Matroska/Utils.pm b/TOOLS/lib/Parse/Matroska/Utils.pm
new file mode 100644
index 0000000000..127d626cb1
--- /dev/null
+++ b/TOOLS/lib/Parse/Matroska/Utils.pm
@@ -0,0 +1,37 @@
+use strict;
+use warnings;
+
+# ABSTRACT: internally-used helper functions
+package Parse::Matroska::Utils;
+
+use Exporter;
+our @ISA = qw{Exporter};
+our @EXPORT_OK = qw{uniq uncamelize};
+
+=method uniq(@array)
+
+The same as L<List::MoreUtils/"uniq LIST">.
+Included to avoid depending on it since it's
+not a core module.
+
+=cut
+sub uniq(@) {
+ my %seen;
+ return grep { !$seen{$_}++ } @_;
+}
+
+=method uncamelize($string)
+
+Converts a "StringLikeTHIS" into a
+"string_like_this".
+
+=cut
+sub uncamelize($) {
+ local $_ = shift;
+ # lc followed by UC: lc_UC
+ s/(?<=[a-z])([A-Z])/_\L$1/g;
+ # UC followed by two lc: _UClclc
+ s/([A-Z])(?=[a-z]{2})/_\L$1/g;
+ # strip leading _ that the second regexp might add; lowercase all
+ s/^_//; lc
+}