in reply to Mapping a drive with Win32::Fileop

There's gotta be a better way to avoid backslash-hell. How about:
my $b = "\\"; $sh = "$b${b}machine1${b}d\$";
or is there another perl mechanism that can ease the pain of dealing with backslashes and other meta-characters in strings?

Of course, the best way it avoid using them, but what if you are forced to?

Replies are listed 'Best First'.
Re^2: Mapping a drive with Win32::Fileop
by ikegami (Patriarch) on May 12, 2008 at 01:24 UTC

    He can get away with only one extra slash if he uses single quotes: '\\\machine\d$'. But that's just confusing the issue. Remembering how to do it these ways is harder than learning how it works.

    Alternatively, he could use '//machine/d$' since Windows accepts either slashes. Tools don't necessarily accept either slash (especially unquoted), but the system does.

Re^2: Mapping a drive with Win32::Fileop (\\)
by tye (Sage) on May 12, 2008 at 04:02 UTC
    ( my $b= '//machine1/d$' ) =~ tr-/-\\-;

    - tye