in reply to change forward slash to backslash

See this thread.


Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan

Replies are listed 'Best First'.
Re^2: change forward slash to backslash
by Eric23 (Initiate) on Nov 20, 2005 at 07:56 UTC
    Thank you for answer. But it seem doesn't work. $string = 'c:/windows/'; $string =~ tr{/}{\}; print $string; Am I right?? But when I run I get this message "Transliteration replacement not terminated at AIFF_test.pl" why?

      The \ needs to be quoted. It is an 'escape' character that allows you to treat special characters normally and normal characters specially. In this case it is quoting the }, which is not what you want.

      use warnings; use strict; my $str = 'c:/windows/'; $str =~ tr{/}{\\}; print $str;

      Prints:

      c:\windows\

      DWIM is Perl's answer to Gödel