Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 15th, 2001, 06:33 AM
Flink Flink is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Location: Manchester, UK
Posts: 47 Flink User rank is Private First Class (20 - 50 Reputation Level)Flink User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 48 m 9 sec
Reputation Power: 8
Decrementing Files

I need to create a Perl script to decrement text files. I can do this for one file at a time given its name. Lets say there's a file for each day of the year. But I need the user to select two dates (say 30/03/01 to 14/04/01), and all files in between these have to be decremented.
Now I can open and edit the filenames selected (e.g. 310301.dat and 140401.dat), but how can I do the same to all the files for the dates inbetween?

Thanks
Flink

Reply With Quote
  #2  
Old June 16th, 2001, 11:14 AM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
i suggest you change the names of your files from day/month/year.txt to year/month/day.txt eg.

20010302.txt == march 2nd, 2001.
20010415.txt == march 2nd, 2001.

Code:
my $lowDate = $userLowYear . $userLowMonth . $userLowDay;
my $highDate = $userHighYear . $userHighMonth . $userHighDay;

foreach $file ( @listOfFilesWithoutTxtExtension ) {
 next if $file < $lowDate;
 next if $file > $highDate;
 # do stuff
}


that should work .. atleast the logic should work .. if my exact example is flawed it's because i haven't had my coffee yet this morning.

you should get the idea, if not write back and i'll try to be more awake the next time i explain it.

Reply With Quote
  #3  
Old June 18th, 2001, 03:52 AM
Flink Flink is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Location: Manchester, UK
Posts: 47 Flink User rank is Private First Class (20 - 50 Reputation Level)Flink User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 48 m 9 sec
Reputation Power: 8
Thumbs up Thanks

Cheers mate. Appreciate it.

Flink

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Decrementing Files


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway