in reply to pass a variable or string to shell command from perl script
First of all, marto is right that you don't need to call an external command for this, there is mkdir, and also make_path from the core module File::Path (Update: which can do the equivalent of mkdir -p). For proper handling of filenames, see the core module File::Spec, or, with a nicer interface, Path::Class from CPAN.
use File::Spec::Functions qw/catdir/; use File::Path qw/make_path/; make_path(catdir('folderA','folderB','folderC')); # Update 2: OR: use Path::Class qw/dir/; dir('folderA','folderB','folderC')->mkpath;
Only for the sake of completeness: I wrote about different ways to call external commmands (safely) at length here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pass a variable or string to shell command from perl script (updated)
by thadc (Novice) on Dec 28, 2017 at 16:54 UTC |