CPANPLUS-YACSmoke
view release on metacpan or search on metacpan
lib/CPANPLUS/YACSmoke/SortVers.pm view on Meta::CPAN
# the same terms as Perl itself.
package CPANPLUS::YACSmoke::SortVers;
$CPANPLUS::YACSmoke::SortVers::VERSION = '1.08';
require Exporter;
@ISA=qw(Exporter);
@EXPORT=qw(&versions &versioncmp);
@EXPORT_OK=qw();
sub versioncmp( $$ ) {
my @A = ($_[0] =~ /([-.]|\d+|[^-.\d]+)/g);
my @B = ($_[1] =~ /([-.]|\d+|[^-.\d]+)/g);
my ($A, $B);
while (@A and @B) {
$A = shift @A;
$B = shift @B;
if ($A eq '-' and $B eq '-') {
next;
} elsif ( $A eq '-' ) {
lib/CPANPLUS/YACSmoke/SortVers.pm view on Meta::CPAN
}
} else {
$A = uc $A;
$B = uc $B;
return $A cmp $B if $A cmp $B;
}
}
@A <=> @B;
}
sub versions() {
my $callerpkg = (caller)[0];
my $caller_a = "${callerpkg}::a";
my $caller_b = "${callerpkg}::b";
no strict 'refs';
return versioncmp($$caller_a, $$caller_b);
}
=head1 NAME
Sort::Versions - a perl 5 module for sorting of revision-like numbers
( run in 0.269 second using v1.01-cache-2.11-cpan-65fba6d93b7 )