[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] MacPerl and type 1s and 2s (fwd)



Well, without seeing your code it's kind of hard to tell
what might be wrong too.  :-)

Generally, what I've done in the past is to have two
lists.  One is the file list and one is the directory
list.  You start off by putting the top level directory
into the directory list, read in all of the files from that
directory, remove that directory from the list, put all
subdirectories into the directory list, process the files,
and continue.  Even with a couple thousand
files/directories in any given directory you can not cause
MacPerl to fail doing this.  Here the above is in pseudo
code:

	@theDirectory = ();

	$theDirectory[0] = "my.top.level.directory";
	while( $#theDirectory > 0 ){
		$curDirectory = splice( @theDirectory, $#theDirectory, 1 );
		@theFiles = ();
#
#	Next you opendir/readdir/closedir the files which are in the directory.
#	There is an excellent example in the manuals (online and book).
#
		for( $i=0; $i<=$#theFiles; $i++ ){
			if( -d $theFiles[$i] ){
				$theDirectory[++$#theDirectory] = $theFiles[$i];
				}
				else{
#
#	It isn't a directory so we look at the file to see if it is valid or not.
#
					}
			}
		}

That's it for the loop.  The above will go through as many
directories as you have and then you can do your tests.
Notice though that you should always clear out the old list
of files (the "@theFiles = ();" up there).  This causes
Perl to perform garbage collection if it needs to do so.
You don't need anything else so far as I know.  Chris?
Paul?  Anyone else?

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch