Maybe this will settle the confusion about whether to use a backslash \ or a forward slash / when using a path name for Perl on Windows.
Every Windows I've ever run Perl on (Windows 2000 and newer) have accepted the forward / just fine, even when using absolute path names like "C:/Users/Kirsle/Desktop/test.txt", and I only would've thought that "pure" DOS systems would be the only ones that don't like forward slashes.
So, I decided to test it on DOS. I have a virtual machine that's running MS-DOS 6.22 with Windows 3.1 and I installed Perl 5.003_93 from the CPAN ports page. Here is my test on directory delimiters:
The results? Forward slashes and backward slashes are interchangeable. Also note that the "../../" format worked fine too, even though (even nowadays in the Windows 7 command prompt), it doesn't like you to use that format on the command line.
So, use forward slashes in your path names in Perl: it's easier to read (/ vs \\) and is portable to non-Windows platforms, provided you use relative pathnames and not drive letters.
Cuvou.com | My personal homepage
Every Windows I've ever run Perl on (Windows 2000 and newer) have accepted the forward / just fine, even when using absolute path names like "C:/Users/Kirsle/Desktop/test.txt", and I only would've thought that "pure" DOS systems would be the only ones that don't like forward slashes.
So, I decided to test it on DOS. I have a virtual machine that's running MS-DOS 6.22 with Windows 3.1 and I installed Perl 5.003_93 from the CPAN ports page. Here is my test on directory delimiters:
Code:
C:\>cd C:\usr\bin
C:\USR\BIN>perl -v
This is perl, version 5.003_93
Copyright 1987-1997, Larry Wall
OS/2 port Copyright (c) 1990, 1991, Raymond Chen, Kai Uwe Rommel
Version 5 port Copyright (c) 1994-1997, Andreas Kaiser, Ilya Zakharevich
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
C:\USR\BIN>type C:\tests\pathtest.pl
#!/usr/bin/perl -w
print "-== Test #1 ==-\n";
open (WRITE, ">C:/WINDOWS/TEST/ONE.TXT") or warn "Can't write file: $!";
print WRITE "This is test #1 being successful";
close (WRITE);
print "-== Test #2 ==-\n";
open (WRITE, ">C:\\WINDOWS\\TEST\\TWO.TXT") or warn "Can't write file: $!";
print WRITE "This is test #2 being successful";
close (WRITE);
print "-== Test #3 ==-\n";
open (WRITE, ">../../WINDOWS/TEST/THREE.TXT") or warn "Can't write file: $!";
print WRITE "This is test #3 being successful";
close (WRITE);
C:\USR\BIN>perl C:\tests\pathtest.pl
-== Test #1 ==-
-== Test #2 ==-
-== Test #3 ==-
C:\USR\BIN>cd C:\windows\test
C:\WINDOWS\TEST>dir
Volume in drive C is MS-DOS_6
Volume Serial Number is 3A4C-5BEF
Directory of C:\WINDOWS\TEST
. <DIR> 06-04-09 12:01p
.. <DIR> 06-04-09 12:01p
ONE TXT 32 06-04-09 12:09p
TWO TXT 32 06-04-09 12:09p
THREE TXT 32 06-04-09 12:09p
5 file(s) 96 bytes
995,213,312 bytes free
C:\WINDOWS\TEST>type one.txt
This is test #1 being successful
C:\WINDOWS\TEST>type two.txt
This is test #2 being successful
C:\WINDOWS\TEST>type three.txt
This is test #3 being successful
C:\WINDOWS\TEST>
The results? Forward slashes and backward slashes are interchangeable. Also note that the "../../" format worked fine too, even though (even nowadays in the Windows 7 command prompt), it doesn't like you to use that format on the command line.
Code:
C:\USR\BIN>cd ../../WINDOWS/TEST
Invalid switch - /..
So, use forward slashes in your path names in Perl: it's easier to read (/ vs \\) and is portable to non-Windows platforms, provided you use relative pathnames and not drive letters.
Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'