Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: [Soved] Re^2: File::Find - Traverse the first level directories from starting point - How?

by 1nickt (Canon)
on May 19, 2020 at 05:47 UTC ( [id://11116925]=note: print w/replies, xml ) Need Help??


in reply to [Soved] Re^2: File::Find - Traverse the first level directories from starting point - How?
in thread File::Find - Traverse the first level directories from starting point - How?

Great, thanks for the feedback!

A slightly more idiomatic way of writing your code:

use strict; use warnings; use Path::Tiny; my $dir = '//192.168.1.44/somedir'; path( $dir )->visit( sub { print "$_\n" if /^[^.]/ && $_->is_dir; });

Note that your code reads the names of all the files (plain files and directories) into two different variables; also I'm not sure about the regexp, it's not clear from your comment what names you are wanting to skip. The file/dir name at that point in the loop shouldn't have a leading slash IIUC.

Hope this helps!

Update: s/all the files/names of all the files/ thx soonix

The way forward always starts with a minimal test.
  • Comment on Re: [Soved] Re^2: File::Find - Traverse the first level directories from starting point - How?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-20 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found