in reply to Re: subs && typeglobs
in thread subs && typeglobs
OK so you are hand rolling the old recurse the directory tree chestnut. Here is a script that will do that for you putting all the dirs in @dirs and all the files in @files. I presume you already know about File::Find so won't do the use a module mantra. There is an explanation of this code here
#!/usr/bin/perl -w use strict; my $root = 'c:/cluster1/'; my @dirs = ($root); my @files; for my $path (@dirs){ opendir ( DIR, $path ) or next; # skip dirs we can't read while (my $file = readdir DIR) { # skip the dot files next if $file eq '.' or $file eq '..'; # skip symbolic links to avoid infinite loops next if -l $path.$file; if ( -d $path.$file ) { # add the dirs to our dir list (full path) push @dirs, $path.$file.'/'; } else { # add the files to file list push @files, $path.$file; } } closedir DIR; } print "Directory list\n\n"; print "$_\n" for sort @dirs; print "\n\nFile List\n\n"; print "$_\n" for sort @files;
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: subs && typeglobs
by s0ttle (Scribe) on Aug 04, 2001 at 13:44 UTC | |
by tachyon (Chancellor) on Aug 04, 2001 at 14:49 UTC | |
by s0ttle (Scribe) on Aug 04, 2001 at 15:41 UTC |