Re: Reading a files in a folder
For a start: my $months_dir = '.'; opendir(DIR, $months_dir); my @months = readdir(DIR); closedir(DIR); foreach my $month (@months) { if (!-d $months_dir/$month || $month eq '.' || $month eq '..') { next; # skip if not dir, or if it is . or .. } opendir(DIR, $months_dir/$month); my @days = readdir(DIR); closedir(DIR); foreach my $day (@days) { if (!-f $months_dir/$month/$day) { next; # skip if not file } # do stuff with $day file print $months_dir/$month/$day\n; } } Geetha Weerasooriya wrote: Hi , I have data files which are in different folders. I want to run the same program on all the data files. For example I have 12 folders for 12 months of the year and each folder contains the files for each day of the month. So one file contains 30 or 31 files. Can some one kindly guide me to do this? Or can you give any reference material to study this type of data handling? Thanks in advance. Best wishes, Geetha -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Reading a files in a folder
Hi , I have data files which are in different folders. I want to run the same program on all the data files. For example I have 12 folders for 12 months of the year and each folder contains the files for each day of the month. So one file contains 30 or 31 files. Can some one kindly guide me to do this? Or can you give any reference material to study this type of data handling? Thanks in advance. Best wishes, Geetha
Re: Reading a files in a folder
Geetha Weerasooriya wrote: Hi , Hello, I have data files which are in different folders. I want to run the same program on all the data files. For example I have 12 folders for 12 months of the year and each folder contains the files for each day of the month. So one file contains 30 or 31 files. or 28 or 29 files. Can some one kindly guide me to do this? Or can you give any reference material to study this type of data handling? It sounds like a fairly simple directory structure. What are you having problems with? John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/