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. :-)
---
demerphq
<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
|