[SOLVED] Suggestions regarding processing files using perl
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I am looking for some suggestions if possible, regarding processing the files using perl script.
Scenario is I have a location where new files will be added always. I need to process these files for some validation. I wrote a perl script to do this and I thought I can rename the files once they are processed in that way I dont process the same files again. But now I can't rename the files due to some restrictions.
Second thought, to process them based on date stamp but as my perlscript is being automated and runs every one hour to process the files I can't go by date stamp.
I can't move or delete the processed files. So is there any way I could do this.
Thanks,
Hi,
I am looking for some suggestions if possible, regarding processing the files using perl script.
Scenario is I have a location where new files will be added always. I need to process these files for some validation. I wrote a perl script to do this and I thought I can rename the files once they are processed in that way I dont process the same files again. But now I can't rename the files due to some restrictions.
Second thought, to process them based on date stamp but as my perlscript is being automated and runs every one hour to process the files I can't go by date stamp.
I can't move or delete the processed files. So is there any way I could do this.
Thanks,
Well, you could output the names of the file(s) you process into a text-file, then look at it to see if the file name is in there. If not, process it, and add it to the text file when done. But, each new add will make the process take more time, but unless you're talking about many thousands, it should be ok.
The timestamp makes sense, but your comment doesn't. If the perl script is being run every hour, who cares? It's the date on the FILES that you're looking at. So if you know the perl program runs every 30 minutes, get the start time going in, and check the time stamps on the files, to see if they were created within the last 30 minutes...if so, process them. You could even use a system-call to find, with the ctime/atime/etc., parameters, and build an array variable of files that meet your criteria, and process them easily.
Hi,
Thank you for the suggestion. If possible can I get help in implementing atime in perl. For example I need to process files that are not accessed for the last 30 minutes.
Hi,
Thank you for the suggestion. If possible can I get help in implementing atime in perl. For example I need to process files that are not accessed for the last 30 minutes.
Thanks,
Yes, very possible. Google for it...lots of docs out there. Or you can re-read my last post, where I suggested you use a system-call to find, and define that as an array-variable.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.