用目录名中的正斜杠创建目录树
试图创建一个目录树,其中一个目录的名称中有一个正斜杠 (/).请参阅 $artist 变量了解艺术家姓名和我创建目录的尝试.
Trying to create a directory tree in which one of the directories has a forward slash (/) in the name. See the $artist variable for the artist name and my attempts at creating the directory.
#!/usr/bin/perl
use warnings;
use strict;
use File::Path qw(make_path);
my $srcpath = '/home/<username>;/music';
my $artist = "";
my $album = 'somealbum';
# Using single quotes
#t1
$artist = 'AC/DC';
make_path("${srcpath}/t1/${artist}/${album}/");
#t2
$artist = 'AC//DC';
make_path("${srcpath}/t2/${artist}/${album}/");
#t3
$artist = 'AC\/DC';
make_path("${srcpath}/t3/${artist}/${album}/");
# Using double quotes
#t4
$artist = "AC/DC";
make_path("${srcpath}/t4/${artist}/${album}/");
#t5
$artist = "AC//DC";
make_path("${srcpath}/t5/${artist}/${album}/");
#t6
$artist = "AC\/DC";
make_path("${srcpath}/t6/${artist}/${album}/");
#t7
$artist = "AC\\/DC";
make_path("${srcpath}/t7/${artist}/${album}/");
我想要的目录树(5 个文件夹):
/-> 主页 -> -> 音乐 -> AC/DC -> 专辑
Directory tree I want (5 folders):
/ -> home -> <username> -> music -> AC/DC -> somealbum
我得到的目录树(6 个文件夹):
/-> 主页 -> -> 音乐 -> AC -> DC -> somealbum
Directory tree I get (6 folders):
/ -> home -> <username> -> music -> AC -> DC -> somealbum
斜线字符是文件名或目录名的非法字符.您需要替换一些其他字符,例如破折号.
The slash character is an illegal character for a file or directory name. You will need to substitute some other character, like the dash character.