| Author |
Absolute paths with multiple volumes
|
|
| Donald 2004-03-18, 6:47 pm |
| 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.
| |
|
| At 2004-03-07 21:37 +1030, 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
>
perldoc File::Spec
Look at the rel2abs() function.
| |
| Donald 2004-03-18, 6:47 pm |
|
"lemma" <lemma@despammed.com> wrote in message
news:20040307124439.GD30750@fleece...
> At 2004-03-07 21:37 +1030, Donald wrote:
command[color=darkred]
name[color=darkred]
D:)[color=darkred]
>
> perldoc File::Spec
>
> Look at the rel2abs() function.
Thanks for the thought. Unfortunately
print File::Spec->rel2abs( 'D:fred', 'D:' ) ;
prints C:\perldev\boms\fred
which is what the doco for File::Spec suggests it will do. Because D: is a
relative path File::Spec first wants to convert this to an absolute path.
So it is stuck with trying to make a path out of "C:\perldev\boms\D:"
Not so simple.
| |
|
| At 2004-03-08 00:27 +1030, Donald wrote:
> "lemma" <lemma@despammed.com> wrote in message
> news:20040307124439.GD30750@fleece...
> command
> name
> D:)
>
> Thanks for the thought. Unfortunately
> print File::Spec->rel2abs( 'D:fred', 'D:' ) ;
> prints C:\perldev\boms\fred
>
I can't try it right now as I don't have a Windows system to hand, but
have you looked at
Win32::GetFullPathName()
| |
| Donald 2004-03-18, 6:47 pm |
|
"lemma" <lemma@despammed.com> wrote in message
news:20040307192934.GB31407@fleece...
> At 2004-03-08 00:27 +1030, Donald wrote:
and[color=darkred]
C:[color=darkred]
>
> I can't try it right now as I don't have a Windows system to hand, but
> have you looked at
>
> Win32::GetFullPathName()
Thanks - that worked a treat. I guess my next question now is where does
one find a good searchable reference for perl functions and modules ?
| |
| Jürgen Exner 2004-03-18, 6:47 pm |
| Donald wrote:
> Thanks - that worked a treat. I guess my next question now is where
> does one find a good searchable reference for perl functions
On your very own harddrive: "perldoc perlfunc"
> and modules ?
On CPAN
jue
|
|
|
|