$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")

In reply to (tye)Re2: Perl - Read a file on another server by tye
in thread Perl - Read a file on another server by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.