On Tue, 06 Sep 2005, Sisyphus wrote: "Randy Kobes" wrote:
> I'm still puzzled by that backslash-escape issue, however:
> 
> D:\pscrpt>type try.pl
> 
> use warnings;
> $z1 = "hello\tworld";
> print $z1, "\n";
> $z2 = "hello\\tworld";
> print $z2, "\n";
> system("rmdir $z2");
> 
> D:\pscrpt>perl try.pl
> hello   world
> hello\tworld
> rmdir: `hello\\tworld': No such file or directory
> 
> D:\pscrpt>
> 
> (That's still using the MSYS/bin/rmdir.exe.)

It is rmdir.exe that doubles the backslash before printing it.  Just run

    rmdir.exe foo\bar

and it will print

    rmdir.exe: `foo\\bar': No such file or directory
 
or

    rmdir.exe foo^Abar

(the ^A should be a single Control-A, not 2 separate characters)
prints

    rmdir.exe: `foo\001bar': No such file or directory

using the octal notation for ^A

Cheers,
-Jan


> I *think* I understand. When print() receives the argument $z2, it receives
> "hello\\tworld" - and it's the print() function that decides that the first
> backslash escapes the second. When rmdir receives the argument $z2, it also
> receives "hello\\tworld", but it doesn't recognize the backslash as an
> escape and treats it literally. Is that right ?
> 
> Up until now, I've always thought that when print() receives the argument
> $z2, it actually receives "hello\tworld" as its argument and prints
> (literally) that. I guess that assumption is (and always was) wrong. If that
> assumption were correct, then we'd have to accept that the $z2 that print()
> receives is different to the $z2 that rmdir receives - and I find it
> difficult to reconcile such a difference.
> 
> Cheers,
> Rob
> 
> 
> _______________________________________________
> Perl-Win32-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to