http://www.perlmonks.org?node_id=955299


in reply to Re: getting next 5 files according to hour
in thread getting next 5 files according to hour

Here is code for the same. You need to change path to where that files are..
my $hour = (localtime)[2]; my $nu=0; if($hour eq 0) {$hour= 23;} else {$hour--;} my @files1 = <dir path of you file>; i.e. <C:\\WINDOWS\\*.log>; while($nu < 6) { if($hour>23) {$hour = 0;} my $hr= sprintf("%02d",$hour); foreach my $file (@files1) { if($file =~ /_($hr)\.txt/ ) {print $file . "\n";} } $hour++; $nu++; }