Phoenix.pm: Best Methods on Win32

Scott Thompson scottcodes at thepurplehaze.com
Mon Nov 10 18:11:13 CST 2003


> -----Original Message-----
> From: owner-phoenix-pm-list at pm.org
> [mailto:owner-phoenix-pm-list at pm.org]On Behalf Of Scott Thompson
> Sent: Monday, November 10, 2003 1:49 PM
> To: phoenix-pm-list at happyfunball.pm.org
> Subject: RE: Phoenix.pm: Best Methods on Win32
>
> Devil's advocate, for those on the list who might be New To Perl,
> here's what I'm working on so far:
>

Here's the "final" version I got working.  FYI, the output is "designed" to
be dumped into a CSV file for review in Microsoft Excel.

Comments and suggestions definitely welcome.

------------------------------>8  Cut 8<------------------------------
#!perl -w
use strict;

# Global variables...
my $pathDepth = 0;
my $pathRoot = $ARGV[0] ? $ARGV[0] : "C:\\Program Files";
my $pathMax = $ARGV[1] ? $ARGV[1] : 50;

# Main code section...
procDir($pathRoot);

# Function code section...
sub procDir {
	my $localRoot = shift;
	opendir (ROOT, $localRoot) || die "Cannot open directory $pathRoot: $!\n";
	my @pathSubdirs = grep {!/^\./ && -d "$localRoot\\$_"} readdir(ROOT);
	rewinddir (ROOT);
	my @pathFiles = grep {-f "$localRoot\\$_"} readdir(ROOT);
	closedir (ROOT);

	foreach my $pathFile (@pathFiles) {
		if (length("$localRoot\\$pathFile") > $pathMax) {
			print "\"$localRoot\\$pathFile\"," . length("$localRoot\\$pathFile") .
"\n";
		}
	}
	foreach my $pathSubdir (@pathSubdirs) {
		$pathDepth++;
		procDir("$localRoot\\$pathSubdir");
		$pathDepth--;
	}
}
------------------------------>8  Cut 8<------------------------------

Scott




More information about the Phoenix-pm mailing list