Created
April 30, 2013 09:10
-
-
Save gnosek/5487556 to your computer and use it in GitHub Desktop.
A simple way to sort Debian package versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Dpkg::Version; | |
use Getopt::Long; | |
my $head; | |
my $reverse; | |
Getopt::Long::Configure ("bundling"); | |
GetOptions( | |
"h|head" => \$head, | |
"r|reverse" => \$reverse, | |
); | |
my @versions = <>; | |
chomp @versions; | |
my @deb_versions = sort map { Dpkg::Version->new($_) } @versions; | |
@deb_versions = reverse @deb_versions if $reverse; | |
$, = "\n"; | |
$\ = "\n"; | |
if ($head) { | |
print shift @deb_versions; | |
} else { | |
print @deb_versions; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment