in reply to How to get sub-folder names using perl?
But i am having a little bit of a time trying to understand the question. This will only create folders in "result" directory if there are folders in "test" directory. The actual file handling wouldnt be much more trivial than this ;)use strict; use warnings; use File::Path qw( make_path ); use File::Slurp; use Cwd; my $cwd = getcwd(); my @dirs = read_dir($cwd); for(@dirs){ next unless -d $_; make_path( "$cwd/result/$_" ); open (my $file, '>', "$cwd/result/$_/test file for $_.txt") or die + "$!"; print $file "this is a test for directory $_"; #or print calculati +on to $file }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get sub-folder names using perl?
by erhan (Novice) on Mar 08, 2015 at 05:49 UTC | |
by Laurent_R (Canon) on Mar 08, 2015 at 10:39 UTC | |
by Happy-the-monk (Canon) on Mar 08, 2015 at 10:54 UTC | |
by Laurent_R (Canon) on Mar 08, 2015 at 11:05 UTC |