in reply to Does Perl Support Absolute paths

These are called UNC paths, not absolute paths.

As shown above,

print '\\\\netbiosname\\sharename', $/;
results in
\\netbiosname\sharename
I would not recommend the suggestion to emply the "net use" command to temporarily connect such a UNC path to a drive letter. It may simplify path handling but it's just as easy to accidentally run into conflicts with which drive letter to assign, whether you can disconnect the drive letter when done, or which drive letter was assigned when you save these strings.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^2: Does Perl Support Absolute paths
by Jenda (Abbot) on Nov 07, 2007 at 23:39 UTC

    Why shell out if you can do this from within the script, with better chance to handle errors (if any).

    use Win32::FileOp qw(Map); Map 'H:' => '\\\\server\\share', {persistent => 1} or die "Failed to map the drive: $^E\n"
      Thanks a lot monks regarding this issue. I would rather run it directly from the UNC path(and not absolute path..thank you for that too) as there would be 10-15users running the script from their WorkMachine and I dont knw which drive is available for them to map it on. I will definitely try this when I reach work tommorrow. Sincere Thanks Ashes.cfg

        Sure, just make sure you have enough backslashes :-)

        You should only need to map the share if you have a program that doesn't accept UNCs or if you need to run a program with the path being the current directory. Because current directory can't be UNC.

        If you do happen to need that you can find out what drives are mapped and which ones are free by Win32::FileOp::Mapped(), or you can call the Map() like this:

        my $drive = Map '\\\\server\\share'; chdir("$drive\\some\\directory");

        Hello Monks, Well I am @ work now and i tried doing what you told.. UNC path is getting accepted...its just that the script gives me the following problem "CMD.EXE was started with the above path as the current directory. UNC paths are not supported.Defaulting to Windows directory" Above path is the UNC path.