我对unlink()
这里完全感到困惑:
my $file = "\"/home/user/Documents/Programming/Perl/extracted/Prueba con formateo HTML/msg-2575-4.html\"";
unlink($file) or warn "Could not unlink $file: $!";
会抛出
Could not unlink "/home/user/Documents/Programming/Perl/extracted/Prueba con formateo HTML/msg-2575-4.html": No such file or directory
虽然文件实际存在:
$ ls -l "/home/user/Documents/Programming/Perl/extracted/Prueba con formateo HTML/msg-2575-4.html"
-rw-rw-r-- 1 user user 413 Mar 25 13:41 /home/user/Documents/Programming/Perl/extracted/Prueba con formateo HTML/msg-2575-4.html
编辑:我也试过:
my $file = "/home/user/Documents/Programming/Perl/extracted/Prueba con formateo HTML/msg-2575-4.html";
my $file = '/home/user/Documents/Programming/Perl/extracted/Prueba con formateo HTML/msg-2575-4.html';
my $file = "\'/home/user/Documents/Programming/Perl/extracted/Prueba con formateo HTML/msg-2575-4.html\'";
同样的错误。
EDIT2:choroba 要求的更多测试
-f
使用返回 false测试文件是否存在。
这是真实文件名的十六进制转储:
$ ls "/home/yasin/Documents/Programming/Perl/extracted/Prueba con formateo HTML/msg-2575-4.html" | hexdump -c
0000000 / h o m e / y a s i n / D o c u
0000010 m e n t s / P r o g r a m m i n
0000020 g / P e r l / e x t r a c t e d
0000030 / P r u e b a c o n f o r m
0000040 a t e o H T M L / m s g - 2 5
0000050 7 5 - 4 . h t m l \n
000005a