|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Cheers mate. Appreciate it.
Flink |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Decrementing Files |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|