mit*_*050 4 windows perl filenames
我希望在Windows中通过perl获取没有文件名的路径
我有这样的完整路径:
c:\My_Designs\ipcore_script\test\src\IP_CORE\mux\sus.do
我只需要路径,并希望剥离文件名,如:
c:\My_Designs\ipcore_script\test\src\IP_CORE\mux
> perl -MFile::Basename -wE "say dirname(qq(c:/perl/bin/perl.exe));"
c:/perl/bin
Run Code Online (Sandbox Code Playgroud)
您还可以使用Path :: Class:
#!/usr/bin/env perl
use strict;
use warnings;
use Path::Class;
my $file = file('c:\My_Designs\ipcore_script\test\src\IP_CORE\mux\sus.do');
print $file->parent, "\n";
Run Code Online (Sandbox Code Playgroud)
输出:
C:\My_Designs\ipcore_script\test\src\IP_CORE\mux