mercredi 29 juin 2016

"less than or equal to" operator not working in if condition

my $path="/mnt/splash/logs/";
my $serv= sprintf("splash-%s-%02d%02d%02d-%s",$server,$year,$mon,$date,$hourStart);
my $eserv= sprintf("splash-%s-%02d%02d%02d-%s",$server,$eyear,$emon,$edate,$hourEnd);
print $serv;
print $eserv;
#OPEN THE SPLASH LOGS DIRECTORY AND READ THE FILES PRESENT THEN STORE IT IN ARRAY.

my $remote_dir=sprintf("ssh %s 'ls %s'",$server,$path);
chomp $remote_dir;
my @list=`$remote_dir`;

#FINDING THE ONLY SPLASH LOGS FILES FROM THE DIRECTORY AND STORED IN AN ARRAY USING PUSH METHOD.
my @srt_list= sort @list;
my @arlist=();
my @arrlog=();
my $i=0;
my $filt;
for(@srt_list) {
    if ($_ ge $serv && $_ le $eserv) {
        #my $filter= sprintf("$_\n");
        chomp $_;

        push (@arrlog, $_);
    }
}

Above is the perl code i used to retrieve the logs from the array. I used if condition with the ge and le operators but if i searched for the log file between 20160628-0400.log to 20160629-1000.log this code is giving the logs from 20160628-0400.log to 20160629-0900.log this is not retrieving the log 20160629-1000.log which the end time log i m searching. i dunno how this happening i used le operator that means it should select the logs that is less than or equal log right?

Please clarify this. i really don't wanna add any other check to retrieve the end time log.

Aucun commentaire:

Enregistrer un commentaire