Comparing values in perl


#1

Transfered from Linux Config Disqus comments:

Question:

How to use perl for the following purpose
if ($l3 gt 22.5 and $l3 lt 45){ }
elseif {}


#2

Hi

Let me know if this is what you need:

compare.pl

#!/usr/bin/perl

my $l3=$ARGV[0];

if ($l3 > 22.5 && $l3 < 45) {
        print "Less than AND Greater than
";
        } elsif ($l3 == 50) {
                print "Equal
";
} else {
        print "No match
";
}

Executing with a single argument:


$ ./compare.pl 50
Equal
$ ./compare.pl 11
No match
$ ./compare.pl 25
Less than AND Greater than

Lubos


#3