in reply to s and replace
So you're trying to print out all the directories without the path attached onto them? If so, this might work:
use warnings; use diagnostics; use strict; my %config = ( home => '/home/cjf/' ); my %user = ( site_id => 'code' ); finddir("$config{home}$user{site_id}"); sub finddir { my $root = shift; chomp $root; $root = $root . '/' unless ( $root =~ m|/$| ); opendir ( DIR, $root ) or die "Can't open Directory: $!"; my @userfiles = sort grep !/^\.\.?\z/, readdir DIR; foreach my $file (@userfiles) { next unless ( -d "$root$file" ); print $file, "\n"; finddir("$root$file"); } }
You might want to consider File::Find as well.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Find and Print Directory Names
by andrew (Acolyte) on Jul 07, 2002 at 17:19 UTC | |
by cjf (Parson) on Jul 07, 2002 at 17:29 UTC | |
by andrew (Acolyte) on Jul 07, 2002 at 17:39 UTC | |
by runrig (Abbot) on Jul 07, 2002 at 17:46 UTC | |
by ehdonhon (Curate) on Jul 07, 2002 at 19:04 UTC |
In Section
Seekers of Perl Wisdom