I would like to convert a relative path to absolute path in a perl script. My understanding was, File::Spec->rel2abs would be able to handle it gracefully, but in the following scenario, I am not getting the expected result
c:\Temp>cat test.pl
use File::Spec;
print File::Spec->rel2abs($ENV{'VS100COMNTOOLS'} . '../../VC/bin/vsvars32.bat');
c:\Temp>perl test.pl
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\..\..\VC\bin\vsvars32.bat
I was expecting something similar to
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vsvars32.bat
Perl Version v5.6.1 built for for MSWin32-x86-multi-thread (ActiveState Corp.)
To Make it Clearer, I would like to achive something similar to the following Python Code
>>> os.path.abspath(os.path.join(os.environ['VS110COMNTOOLS'], r'..\..\VC\bin\vsvars32.bat'))
'C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\bin\\vsvars32.bat'
You can also do this with the Cwd core module:
use Cwd 'abs_path';
my $abs_path = abs_path($file);
(Example taken directly from the documentation).
However, you should definitely upgrade your Perl. Perl 5.6.1 was actually released over 12 years ago. There have been great advances, both in the language generally and in Windows support, since then.
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