uksza has asked for the wisdom of the Perl Monks concerning the following question:
Wise Monks,
It's hard to say what I need, so I use some examples:
Thanks for your help and time,
greetz, Uksza
Yes, smart people know that fat arrow autoquotes the left argument. But why should you require your code to be maintained by smart people?
It's hard to say what I need, so I use some examples:
I have directiories:
So, I use some code from runrig on How do I recurse all *but* a few directories? and I've made this:
without exceptions my directiories list shoud look:/root +dir1 +1a +1b +dir2 +2a +2b +2c
with exception on /root/dir2/2b:/root
/root/dir1 /root/dir2/2a /root/dir2/3a
It works, but I wonder if is any better way to do it? I dont't think about usless $all{$dir}, but about totally difrent way.use File::Find; my @abs_dirs = qw ( /usr/local/share/locale ); my %abs_dirs; @abs_dirs{@abs_dirs} = (); my @OK_dir; my %all; find( sub { $File::Find::prune = 1, return if -d and ( exists $abs_dirs{$File::Find::name} ); my $dir = $File::Find::name; return if -f $dir; if ( ( grep { $_ =~ m/$dir/ } @abs_dirs ) and ( !exists $all{$ +dir} ) ) { $all{$dir}; } else { push @OK_dir, $dir; $File::Find::prune = 1; return; } }, "/usr/local/" );
Thanks for your help and time,
greetz, Uksza
Yes, smart people know that fat arrow autoquotes the left argument. But why should you require your code to be maintained by smart people?
Randal L. Schwartz, Perl hacker
2006-02-21 Retitled by planetscape, as per Monastery guidelines
Original title: 'Directiories without recursion and exceptions'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Directories without recursion and exceptions
by davidrw (Prior) on Feb 21, 2006 at 14:03 UTC | |
by merlyn (Sage) on Feb 21, 2006 at 14:43 UTC | |
by davidrw (Prior) on Feb 21, 2006 at 15:08 UTC | |
by uksza (Canon) on Feb 21, 2006 at 14:58 UTC |
Back to
Seekers of Perl Wisdom