无法使用 make_path 创建目录
Unable to create directory using make_path
我试图使用 Perl 在其中创建一个目录和一个子目录。
这是代码:
#!/usr/bin/perl
use strict;
use warnings;
use Cwd qw(abs_path);
use File::Path qw(make_path remove_tree);
my $path = abs_path();
my @create = make_path($path , '/test/data' , {
verbose => 1,
mode => 0777,
})
or die "failed to create directory /test/data $!";
显示如下错误:-
failed to create directory /test/data at ./perl_project.pl line 7
我做错了什么?
如果要在当前目录创建路径 /test/data
,请更改:
my @create = make_path($path , '/test/data' , {
至:
my @create = make_path($path . '/test/data' , {
# ^
由于您在 make_path 中使用了逗号,因此您的代码尝试创建 2 个目录:一个在当前目录 ($path
) 中,另一个在绝对路径 /test/data
中。
我试图使用 Perl 在其中创建一个目录和一个子目录。 这是代码:
#!/usr/bin/perl
use strict;
use warnings;
use Cwd qw(abs_path);
use File::Path qw(make_path remove_tree);
my $path = abs_path();
my @create = make_path($path , '/test/data' , {
verbose => 1,
mode => 0777,
})
or die "failed to create directory /test/data $!";
显示如下错误:-
failed to create directory /test/data at ./perl_project.pl line 7
我做错了什么?
如果要在当前目录创建路径 /test/data
,请更改:
my @create = make_path($path , '/test/data' , {
至:
my @create = make_path($path . '/test/data' , {
# ^
由于您在 make_path 中使用了逗号,因此您的代码尝试创建 2 个目录:一个在当前目录 ($path
) 中,另一个在绝对路径 /test/data
中。