--- garrett esperum <[EMAIL PROTECTED]> wrote:
> Thanks! That helped,
> This is what my script looks like now:
>
> #!/usr/local/bin/perl -w
>
> use strict;
> use File::Path;
> use File::Copy;
>
> my $file;
> my $type;
> my $currentLocation;
> my $newLocation;
> my $owner;
> my $permissions;
> open (MDATA, "meta-data") or die "Cannot open $!\n";
> while (<MDATA>) {
> chomp;
> ($file, $type, $currentLocation, $newLocation, $owner, $permissions)
> = split /\t/;
> forech $newLocation
> if ( not -d $newLocation );
> mkpath($newLocation, $owner, $permissions) or die "Couldn't
> make the target directory: $!\n";
>
>
> }
> close MDATA
>
> And this is the error I get:
>
> Can't locate object method "forech" via package "www" (perhaps you forgot to
> load "www"?) at ./creat
> ion.pl line 17, <MDATA> line 1.
Aack! I just read the error message and didn't look at the code. There are a few
other issues
there. Here's my guess as to what you were looking for:
#!/usr/local/bin/perl -w
use strict;
use File::Path;
use File::Copy;
open (MDATA, "meta-data") or die "Cannot open $!\n";
while (<MDATA>) {
chomp;
my ($newLocation, $owner, $permissions) = (split/\t/)[ 3.. 5];
foreach ( $newLocation ) {
if ( not -d $newLocation ) {
mkpath($newLocation, $owner, $permissions) or die "Couldn't make the
target
directory: $!\n";
}
}
}
close MDATA
I also wonder if you're misunderstand the use of mkpath(). From 'perldoc File::Path':
File::Path - create or remove directory trees
SYNOPSIS
use File::Path;
mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711);
rmtree(['foo/bar/baz', 'blurfl/quux'], 1, 1);
DESCRIPTION
The "mkpath" function provides a convenient way to create directories,
even if your "mkdir" kernel call won't create more than one level of
directory at a time. "mkpath" takes three arguments:
* the name of the path to create, or a reference to a list of paths to
create,
* a boolean value, which if TRUE will cause "mkpath" to print the name
of each directory as it is created (defaults to FALSE), and
* the numeric mode to use when creating the directories (defaults to
0777)
The second argument is merely a boolean and not the owner.
Also, you have File::Copy in your script, but you don't use it. Is this something you
plan to use
later? If not, having it in your script may confuse someone (namely, me :)
Cheers,
Curtis "Ovid" Poe
=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]