I have a script which will do certain set of operation based on the time in IF condition. So basically IF will look for the Current Time which is Hour and Minutes.
Here is the script:
use strict;
use warnings;
my $TIME = `date '+%H%M'`;
chomp $TIME;
print $TIME."\n";
if (( $TIME > 0100) && ($TIME < 0300)){
print "1st IF\n";
} elsif (( $TIME > 0300) && ($TIME < 0500)){
print "2nd IF\n";
} else {
print "Default IF\n";
}
Lets say now the time is 0130 and it suppose to print 1st IF. But its printing Default IF.
Similarly when the time is 0430 and it suppose to print 2nd IF. But its printing Default IF.
But when I enclose the time value in double quotes "" it works. Like below -
if (( $TIME > "0100") && ($TIME < "0300")){
Do the $TIME is resolving as a string ? I was thinking the $TIME would have numbers and it doesn't require quotes.