Phoenix.pm: Best Methods on Win32

Scott Thompson scottcodes at thepurplehaze.com
Mon Nov 10 14:48:35 CST 2003


> -----Original Message-----
> From: owner-phoenix-pm-list at pm.org
> [mailto:owner-phoenix-pm-list at pm.org]On Behalf Of Scott Walters
> Sent: Monday, November 10, 2003 1:24 PM
> To: Scott Thompson
> Cc: Phoenix-Pm-List at Happyfunball. Pm. Org
> Subject: Re: Phoenix.pm: Best Methods on Win32
>
>
> I'm the last person to ask about Win32 (or BeOS, or DG-UX, or...)
> but I suggest the excellent File::Find. Think of it as a kind of
> opendir() that works recursively. The rename() built-in should be
> all that you need to rename the files. If you did anything more
> complex, then the Win32 object might be handy (depending on what
> it does). If you don't want to rename them at all, I think the
> mkisofs program (google for it) lets you create an .iso file
> and stuff files into it and have them named things completely
> differant than their actual name. This would be the easiest
> way to get rid of excessively verbose path information.
>

And, of course, a module exists to do it, too.

Devil's advocate, for those on the list who might be New To Perl, here's
what I'm working on so far:

------------------------------>8  Cut 8<------------------------------

#!perl -w
use strict;

# Global variables...
my $pathRoot = "C:\\Downloads\\";

# Main code section...
opendir (ROOT, $pathRoot) || die "Cannot open directory $pathRoot: $!\n";
procDir($pathRoot);
closedir (ROOT);

# Function code section...
sub procDir {
	my $localRoot = shift;
	my @pathObjects = readdir(ROOT);

	print "$localRoot contains:\n\tPath Length\tName";
	foreach my $pathObject (@pathObjects) {
		if (-f "$localRoot\\$pathObject") {
			print "\n\t" . length($localRoot . $pathObject) . "\t$pathObject";
		}
	}
}

------------------------------>8  Cut 8<------------------------------

I'm planning on calling procDir() recursively for each -d found.  but I
haven't got that far yet.

Thoughts??

Scott




More information about the Phoenix-pm mailing list