in reply to Re: mkpath()
in thread mkpath()
I sort of golfed this down to the following ( I added a bit of whitespace here to make it more reable, but i get 100 chars for the block part of the sub :-)
use File::Path; use warnings::register; sub umask_mkpath { my@c; umask((umask(shift),@c=eval{mkpath(@_)} or warnings::warnif "Err:$@")[0]); @c }
I omitted the string to numeric conversion you were doing with oct(), because I felt the caller was more likely to know if this was needed or not, and I added the ability it set the umask (the first argument). Otherwise this should behave like mkpath(), expect that if it returns false, the error message will be in $@.
Incidentally I did this mostly because your code reminded me of a trick i'd seen before that avoids using a temporary variable when setting an attribute on a different filehandle without changing the currently selected one.
select((select(STDERR),$|++)[0]); # autoflush STDERR
And I thought I might try to apply the idiom here. Anyway. :-)
|
|---|