Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Perl - Read a file on another server

by eejack (Hermit)
on May 05, 2001 at 04:22 UTC ( [id://78170]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl - Read a file on another server
in thread Perl - Read a file on another server

Howdy jink,

The filename was quoted with single quote marks...
$file = '//Server2/f$/logconn.txt';
which would be fine. However if he were using double quote marks like then you would be correct. Also interesting to not that the direction of the slashes make no real difference on win32 perl.

$file = '//Server2/f$/logconn.txt'; and $file = '\\Server2\f$l\logconn.txt';
are equivalent.

EEjack

Replies are listed 'Best First'.
(tye)Re2: Perl - Read a file on another server
by tye (Sage) on May 05, 2001 at 08:12 UTC

    $file = '//Server2/f$/logconn.txt';
    and
    $file = '\\Server2\f$\logconn.txt';

    are equivalent.

    (I removed the "l" typo)
    Try this:

    print '//Server2/f$/logconn.txt', $/; print '\\Server2\f$\logconn.txt', $/;
    and you'll see
    //Server2/f$/logconn.txt \Server2\f$\logconn.txt
    Use that second one as a file path and Server2 won't even be bothered.

    This is why I always double \ in Perl quoted strings (except for "here documents" which is the one form of quoting in Perl that doesn't treat \ as special) and so would write the second one as: '\\\\Server2\\f$\\logconn.txt' even when using single quotes. Otherwise you get in the habit of thinking that \ isn't special in single quotes and make the mistake you just did (which can be real hard to debug when you do it).

    P.S. Note that / doesn't work as a directory separator when you pass file names as command-line arguments to many Win32 commands. I believe that this is the only exception (well, other than some GUI tools don't allow them either, but most people rarely use Perl to stuff strings into a GUI [though I've done that]).

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-03-28 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found