Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Is this directory a subdirectory of another directory?

by mt2k (Hermit)
on Mar 15, 2002 at 19:30 UTC ( [id://152063]=note: print w/replies, xml ) Need Help??


in reply to Is this directory a subdirectory of another directory?

Okay, in the end I used strat's line of code within a loop to test for each directory.
I tried crazyinsomniac's code, which only printed out one filename in a directory not even included in the path. I probably used it wrong!
So anyway, thanks a lot for your help (and that includes everyone that posted).
I would post the code I now use, but it's quite long... And sorry about the use of HTML there... I noticed that it shrunk the size of the nodelets after I posted it.

Update: Okay, I tried crazyinsomniac's code again, and it worked for the most part, but it still left valid directories out of the options, so I went back with strat's code with a small modification. Here is the code I use now:

my $root_path = "C:/Apache/www-root"; my $count = 0; my $dir = ""; my @dirs find(\&{ sub { if (-d "$File::Find::dir/$_"){ if (++$count == 1) { push @dirs, $File::Find::dir; } else { push @dirs, $File::Find::dir . "/" . $_; } } } }, "$root_path"); foreach $dir (@dirs) { my $tmp_dir = $input{'file' . $i}; my $tmp_dir =~ s/(.*)\/(.*)/$1/; if ($test_this_directory !~ /^\Q$full_file_path/ && $dir ne $tmp_ +dir) { #valid directory - add it to cpoy options } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://152063]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-03-28 19:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found