I am looking to get the path without the filename in windows through perl
I have the full path like this:
c:\My_Designs\ipcore_script\test\src\IP_CORE\mux\sus.do
I need only the path and want to strip off the filename like:
c:\My_Designs\ipcore_script\test\src\IP_CORE\mux
Use File::Basename
> perl -MFile::Basename -wE "say dirname(qq(c:/perl/bin/perl.exe));"
c:/perl/bin
You can also use 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";
Output:
C:\My_Designs\ipcore_script\test\src\IP_CORE\mux
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With