Rob Dixon wrote:
John W. Krahn wrote:
#extract year, month, day when $xfile was last modified
# eg 2008/July/9
my $dir = strftime '%Y/%b/%-d', localtime( ( lstat $xfile )[9] )
I hoped that was what I was looking for, but the format %- creates nothing and
the 'd' is simply.
It works here:
$ perl -MPOSIX -le'print strftime q[%Y/%b/%d * %Y/%b/%-d], localtime
55555555'
1971/Oct/05 * 1971/Oct/5
if ( ! -e $dir ) {
mkpath [ $dir ], 0, 0750 or die "Cannot mkpath '$dir' $!";
}
There is no problem with calling mkpath on an already-existing directory. OTOH
it is documented to throw a fatal error if the path cannot be created so there
is no point in checking the return value (which is the number of directories
created by the call).
perldoc File::Path
[ snip ]
ERROR HANDLING
If "mkpath" or "rmtree" encounter an error, a diagnostic message
will be printed to "STDERR" via "carp" (for non-fatal errors), or
via "croak" (for fatal errors).
So I guess neither of us are correct. :-)
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/