in reply to Re^5: shedding a bash wrapper and updating to Path::Tiny
in thread shedding a bash wrapper and updating to Path::Tiny
Hello Datz_cozee75,
I'm glad you found my post helpful. I don't see mkdir used anywhere in your code. When you refer to mkdir, I assume you are referring to the mkpath method from Path::Tiny that you use in a couple places (not to be confused with the perl function mkdir). So, code like this may need to be changed to do what you want...
The documentation for the Path::Tiny mkpath method states that it returns the list of directories created or an empty list if the directories already exist, just like make_path.. So perhaps this would be more useful,my $folder = path( $current, $to, $ts, $base_dir )->mkpath;
If you wanted to check the return value of the mkpath method, you could store it in a scalar like this,my $folder_path = path( $current, $to, $ts, $base_dir ); $folder_path->mkpath; # This will print the path regardless if the path already existed or n +ot print "My folder path is $folder_path\n";
or if you wanted the list of dirs that were created you could do this,my $mkpath_return_value = $folder_path->mkpath; # The value of $mkpath_return_value will be equal to the number of dir +s created (since the return value will be a list that is forced into # scalar context), or it will be equal to zero if the path already exi +sted.
my @dirs = $folder_path->mkpath;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: shedding a bash wrapper and updating to Path::Tiny
by Aldebaran (Curate) on Jul 26, 2018 at 20:04 UTC |
In Section
Seekers of Perl Wisdom