LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-23-2010, 01:41 PM   #1
user_28
LQ Newbie
 
Registered: Aug 2010
Posts: 27

Rep: Reputation: 0
Question Suggestions regarding processing files using perl


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,
 
Old 08-23-2010, 02:36 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by user_28 View Post
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.
 
Old 08-23-2010, 03:35 PM   #3
user_28
LQ Newbie
 
Registered: Aug 2010
Posts: 27

Original Poster
Rep: Reputation: 0
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,
 
Old 08-23-2010, 03:44 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by user_28 View Post
...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,

perldoc -f stat
 
Old 08-23-2010, 09:01 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by user_28 View Post
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.
 
1 members found this post helpful.
Old 08-26-2010, 12:34 PM   #6
user_28
LQ Newbie
 
Registered: Aug 2010
Posts: 27

Original Poster
Rep: Reputation: 0
Hi,
Thank You. It worked. I have a new problem and I will open a new thread so that it will be easy.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux distro solely for image processing, using GIMP suggestions sought grahamdcp Linux - General 21 05-19-2009 08:31 PM
Perl error message processing 2007fld Programming 2 07-22-2008 07:17 PM
Perl use prima; Prima(perl) (image processing software))error knockout_artist Linux - Software 2 09-11-2007 10:13 PM
perl files download instead of parsed on apache2 mod-perl2 not parsing perl files zeigerpuppy Debian 1 02-16-2006 05:31 AM
help! i need advice and suggestions for fast processing eph General 4 03-17-2004 06:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration