Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: How to get sub-folder names using perl?

by zwon (Abbot)
on Mar 08, 2015 at 22:22 UTC ( #1119263=note: print w/replies, xml ) Need Help??


in reply to How to get sub-folder names using perl?

Nowadays, if I have to do anything with files I use Path::Tiny, it makes code much cleaner. Here's how your script would look with it:
#!/usr/bin/env perl use strict; use warnings; use Path::Tiny; my $dir = Path::Tiny->cwd; my @subdirs = grep { $_->is_dir } $dir->children; my $results = $dir->child('results'); for my $subdir (@subdirs) { my $ressubdir = $results->child($subdir->basename); $ressubdir->mkpath; chdir $subdir; system("pwd > $ressubdir/outfile.txt"); } chdir $dir;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2020-06-03 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (22 votes). Check out past polls.

    Notices?