Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Wise Monks,

It's hard to say what I need, so I use some examples:
I have directiories:
/root +dir1 +1a +1b +dir2 +2a +2b +2c
without exceptions my directiories list shoud look:
/root
with exception on /root/dir2/2b:
/root/dir1 /root/dir2/2a /root/dir2/3a
So, I use some code from runrig on How do I recurse all *but* a few directories? and I've made this:
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/" );
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.
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'


In reply to Directories without recursion and exceptions by uksza

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (None)
    As of 2024-04-25 04:04 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found