Perl 无法使用make\u路径创建目录

Perl 无法使用make\u路径创建目录,perl,Perl,我试图使用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' , {

我试图使用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' , {
致:


由于在中使用了逗号,因此代码尝试创建两个目录:一个位于当前目录(
$path
),另一个位于绝对路径
/test/data

提示:
my$path=abs_path()可以简化为使用
my$path=“.”提示:
my$path=“.”;生成路径($path.'/test/data',…)可以简化为
生成路径('test/data',…)
 my @create = make_path($path . '/test/data' , {
 #                            ^