|
Answer» Hi friends,
I have the following PERL code to get the last modified date and time for the files in a folder.
#!/usr/bin/perl use File::stat;
foreach $ab (ARGV) { $sb = stat($ab) ; printf scalar LOCALTIME $sb->mtime ; print " -- $ab"; print "\n" ; }
The problem with this code is, it is not giving the INFORMATION for all the files if they have same name with different extension, but were modified at the same time.
e.g. if there are 2 files called abcd.exe and abcd.lst in the same folder and have the same last modified date and time, then the above code is giving me only the abcd.lst file last modified date & time info. But my requirement is to print all the files information.
I don't know anything about PERL, and I got the above code is from our company. Please anybody let me know the code to get the last modified date and time for all the files (i.e. in the above e.g. I need to get the last modified date and time for both the files). Thank you very MUCH in advance.the key LIES in ARGV. How are you EXECUTING the script and how many parameters do you pass to the script? if you pass in only abcd.exe, of course the script would give you only 1 result. if you are a beginner with Perl, at least make an effort to study the Perl docs before attempting to change other people's code.Hi gh0std0g74,
Thank you for your help/suggestion.
|