Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2016-10-26 02:09 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.