rjsaulakh,
First, you should check out perldoc -f stat. Next, you should know that depending on the OS, it may be impossible to get the actual create date. Next, you will make your job easier if instead of using dates in the format of DD/MM/YYYY, you use epoch timestamps. You can easily convert using a simple regex and Time::Local. My advice would be to use a time of 00:00:01 for the start range and 23:59:59 for the end range. It is then a simple matter of seeing if one number (from stat) is between two other numbers.
Update: I originally assumed that the list of candidate files was already known and you would just need to determine if each one in succession met the criteria. If that isn't the case and you need to find the files take a look at File::Find, File::Find::Rule, and File::Finder coupled with the general approach in this post.
| [reply] |
I would use Date::Manip or one of the other Date modules to convert your input dates into epoch times. Then, simply do a numerical comparison to see if the mtime for each file is between your bounds. | [reply] |
i have gone through the Date::Manip but was unable to find what can convert my input date in format of dd/mm/yyyy into epoch
| [reply] |
thx for ur help . i am able to get the mtime of the files . i am taking input from user in dd/mm/yyyy format and i am using ParseDateString($string1) to get the epoch time but the problem is that the output in this case is 2005090100:00:00 while the epoch for the same file is 1105215157. do i need to use a different function to get input dates into epoch secs.
| [reply] |
| [reply] |
thx for ur response but i need to take two dates as input from user and compare whether the modified date of the files lies between the two dates taken as input and then take a ll the files matching in an array for later processing
| [reply] |