Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: How to have universal perl script for C and D drive ?

by ikegami (Patriarch)
on Feb 08, 2008 at 17:49 UTC ( [id://667023]=note: print w/replies, xml ) Need Help??


in reply to How to have universal perl script for C and D drive ?

The path to the Program Files directory can be found in the registry at
HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir

The drive in which the script resides can be found using

use File::Spec::Function qw( rel2abs ); my ($drive) = rel2abs($0) =~ /^([A-Z]):/i;

Note that this won't work if the script was launched using a UNC path. ($drive will be undef.)

Replies are listed 'Best First'.
Re^2: How to have universal perl script for C and D drive ?
by jrtayloriv (Pilgrim) on Feb 08, 2008 at 18:03 UTC
    File::Spec::Win32 also provides a splitpath() function which will split the path into $volume, $directories, $filename

    So you could also grab the volume from there.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://667023]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-18 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found