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

Re: How to perform recursion in any OS?

by choroba (Cardinal)
on Dec 08, 2016 at 00:22 UTC ( [id://1177458]=note: print w/replies, xml ) Need Help??


in reply to How to perform recursion in any OS?

Instead of `ls -a $path`, which doesn't work for filenames containing spaces, anyway, use glob, or File::Find or File::Find::Rule, Path::Tiny etc.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: How to perform recursion in any OS?
by betterworld (Curate) on Dec 08, 2016 at 07:48 UTC

    I prefer Path::Class for listing directories:

    use Path::Class qw(dir); my @files = map {$_->basename} dir($path)->children;

    Also check out the docs (perldoc Path::Class::Dir) about the "recurse" function.

    In any case, there are many other reasons why you should never write code like `ls -a $path`. Have you thought about the possibility that $path includes the string "; rm -rf /"?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found