470,614 Members | 1,445 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

Absolute paths with multiple volumes

I am writing a simple perl program that is normally called from the command
line with a filename as an argument. I need the full absolute path and name
for this file. It is for WIN32 system that has multiple volumes (ie C: D:)

Examples
c:\myarea>myscript fred
-----> c:\myarea\fred

c:\myarea>myscript d:fred
-----> d:\current_directroy_of_volume_D\fred

I am new to perl but have searched extensively for a SIMPLE solution. It
seems to be a straightforward enough task and I am wondering whether I am
missing something obvious.

The file in question will always exist and has a file handle if that helps.

Regards
Donald.
Jul 19 '05 #1
1 1654
In article <40********@duster.adelaide.on.net>, Donald wrote:
I am writing a simple perl program that is normally called from the command
line with a filename as an argument. I need the full absolute path and name
for this file. It is for WIN32 system that has multiple volumes (ie C: D:)

Examples
c:\myarea>myscript fred
-----> c:\myarea\fred

c:\myarea>myscript d:fred
-----> d:\current_directroy_of_volume_D\fred


#!perl
use Cwd 'abs_path';
use File::Spec;
($vol, $dir, $file) = File::Spec->splitpath('d:fred');
print File::Spec->catfile( abs_path("$vol$dir"), $file );

Cheers, Roel van der Steen
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by David Siroky | last post: by
7 posts views Thread by Rizaan Jappie | last post: by
reply views Thread by Chris Gill | last post: by
19 posts views Thread by Jerry M. Gartner | last post: by
6 posts views Thread by Jon Slaughter | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.