Hello,

I was wondering whether someone might be able to help me with the following
problem:

How do I replace all instances of a newline in a string in Perl with the
literal value "\n" (minus quotes). For example, if I have the string 

$testValue1  = "a
b";

how can I change it to

$testValue1 = "a\nb";

?

I have tried using pattern matching and regular expressions. Here is what
the code for the substitution I tried:

$testValue1 =~ s/\n/\\n/mg;

So it is supposed to find all newlines, and replace them with "\\n". What
happens, however, is that the newline character seems to remain, but the
"\n" is added. Continuing with the above example, 

$testValue1 = "a
\nb";

Does anyone know what I might be able to do, or have any suggestions? I
would appreciate any response greatly.

thanks,
Yazan

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to