Difference between revisions of "Studio:How do I extract the drive letter and use it to define the location of the Perl module?"
Line 17: | Line 17: | ||
− | [[Category: | + | [[Category:Perl Info]] |
Revision as of 11:09, 29 February 2008
The following code will extract the drive letter and use it to define the location of the Perl module:
use strict; use File::Spec; use vars qw($modulePath); BEGIN { my($vol, undef, undef) = File::Spec->splitpath($main::ascript->Database->Path); $modulePath = File::Spec->catpath($vol, File::Spec->catdir(,'Stride','lib', 'perl', 'S2S')); } use lib qq($modulePath); use TestUtils;
A BEGIN block is evaluated as soon as it is encountered, so the $modulePath value will have a value by the time the 'use lib' statement is encountered.
If libraries are always installed on the system drive, $ENV{'SystemDrive'} can be used to determine the volume. Alternately, a registry setting or environment variable can be used.