Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^2: getting next 5 files according to hour

by bimleshsharma (Beadle)
on Feb 21, 2012 at 13:06 UTC ( #955299=note: print w/replies, xml ) Need Help??

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++; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://955299]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2017-02-27 11:42 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (383 votes). Check out past polls.