0

I have a line of code in my module that looks exactly like this:

make_path($root_dir);

Unfortunately, it doesn't create the desired directory (I have checked, and do have permissions there).

However, if I change it to the following:

make_path($root_dir, {});

It works fine. A couple lines earlier, I'm getting the same odd behaviour with make_path($root_dir); vs make_path($root_dir, {});. Any ideas why this could be?

I'm using perl 5, version 16, and File:Path version 2.09.

4

1 回答 1

3

Path::Class::Dir 类创建基于散列的对象。

make_path的用法是make_path(PATHS, OPTIONS_HASH)

当您将 Path::Class::Dir 对象作为make_path的最后一个参数传递时,它将被视为选项哈希。

您可以通过显式提供选项哈希来解决此问题

make_path($path, {})

或通过显式字符串化路径

make_path("$path")
于 2013-08-24T11:07:02.813 回答