Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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


Comment on Re^2: getting next 5 files according to hour
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://955299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-07-30 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls