summaryrefslogtreecommitdiff
path: root/ngx_stream_lua-0.0.16/util/ver-ge
blob: 8d7a401e943c59fb968bb478fcff994184492375 (plain)
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";