You might want to try using the input line separator system variable
"$/". By default it is "\n", but you can set it to whatever you like
e.g.
$/ = " ";  #This makes the newline character a whitespace

so then
$testValue1  = "a b";

might be what you want to accomplish, I'm not sure,
Hope this helps-
PJD

----- Original Message -----
From: "Fahmawi, Yazan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 10, 2002 4:52 PM
Subject: newline issue


> 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]
>
>


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

Reply via email to