File: ver-ge

package info (click to toggle)
libnginx-mod-http-lua 1%3A0.10.28-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,456 kB
  • sloc: ansic: 42,658; perl: 480; sh: 303; python: 23; makefile: 11
file content (41 lines) | stat: -rwxr-xr-x 557 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env perl

use strict;
use warnings;

sub usage {
    die "Usage: $0 <ver1> <ver2>\n";
}

my $a = shift or usage();
my $b = shift or usage();

my @as = split /\./, $a;
my @bs = split /\./, $b;

my $n = @as > @bs ? scalar(@as) : scalar(@bs);

for (my $i = 0; $i < $n; $i++) {
    my $x = $as[$i];
    my $y = $bs[$i];

    if (!defined $x) {
        $x = 0;
    }

    if (!defined $y) {
        $y = 0;
    }

    if ($x > $y) {
        print "Y\n";
        exit;

    } elsif ($x < $y) {
        print "N\n";
        exit;
    }
}

print "Y\n";