in reply to how to use file::Find ?
Hi again, steph_bow - I guess since I got you started down this road, I might as well keep you going. :) By the way, I note that you're still using a 'BEGIN' block in your code without any specific reason; you should probably read up on these special blocks (the section is called 'BEGIN, UNITCHECK, CHECK, INIT and END') to find out what they're for - and you shouldn't use them gratuitously.
File::Find is a nicely-documented module; you should read up on it by typing 'perldoc File::Find' (the exact case is important) at your command line. The short version, however, is that the 'find' function takes a sub reference as its first argument and a list of directories as the second - as starbolin mentioned. From what I see in your code, you mostly need to learn how to permute lists of directories - something like the following:
(pseudocode) (A B, C) x (D, E, F) = (A/D, A/E, A/F, B/D, B/E, B/F, C/D, C/E, C/F)
In the example that I gave you the last time, I cheated a bit and used brace expansion in the glob statement - i.e., I used the shell to do the work (*bad, bad me...* :) This time, however, I'll do it "the right way", by using 'map':
use warnings; use strict; ### Make up some numbers :) my ($week, $date) = qw/36 250/; my @regs = qw(LAR30 TYE68 SOK96); ### Interpolate the directory lists @dirs = map { "../ALL_WEEKS/semaine_$week/semaine_${week}_TACOT/day_$date/r_$dat +e/$_" } @regs; ### Now that we have our list of directories, process them find(\&process, @dirs); sub process { ### Do stuff to the files returned by File::Find (represented by ' +$_') print "File name: $_\n"; }
-- Human history becomes more and more a race between education and catastrophe. -- HG Wells
|
|---|