In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Guy Tubbs) wrote:
> but it does the same thing, i.e. I get:
>
> Line1
> Line2
>
> What I need is:
>
> Line1Line2
>
> Do you know how to get rid of the returns altogether?
s/\015\012|\015|\012//g;
--
Scott R. Godin| e-mai
Try this if you're using linux/unix system:
$variable =~ s/\n\r//g;
Alex
Guy Tubbs wrote:
>Hi,
>
>Can anyone give me the code that will replace all the carriage returns in a
>variable with another character.
>
>I am getting input from a web page and need to replace the returns with the
> tag.
On Tue, 2 Oct 2001, Guy Tubbs wrote:
> but it does the same thing, i.e. I get:
>
> Line1
> Line2
>
> What I need is:
>
> Line1Line2
>
> Do you know how to get rid of the returns altogether?
Odd. Here's the code snippet I ran right at the command-line:
$ perl
$text = "line1\nline2\n";
$te
gt;;
<[EMAIL PROTECTED]>
Sent: Tuesday, October 02, 2001 9:52 AM
Subject: RE: Replacing carriage returns in a variable
> Thanks for your replies.
>
> It does insert another character, but keeps the return too.
>
> I have tried:
> $text =~ s/\n//g;
>
> and
>
> $text =~
Thanks for your replies.
It does insert another character, but keeps the return too.
I have tried:
$text =~ s/\n//g;
and
$text =~ s/\r//g;
but it does the same thing, i.e. I get:
Line1
Line2
What I need is:
Line1Line2
Do you know how to get rid of the returns altogether?
Guy
--
T
Something like this?
my $othercharacter = 'Z';
$yourvariable =~ s/\r/$othercharacter/g;
# \r is carriage return
# /g at the end means do them all
- Roger -
- Original Message -
From: "Guy Tubbs" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 01, 2001 4:53 PM
Subject
On Mon, 1 Oct 2001, Guy Tubbs wrote:
> Can anyone give me the code that will replace all the carriage returns in a
> variable with another character.
>
> I am getting input from a web page and need to replace the returns with the
> tag.
I tried this:
my $text = "some text\n";
$text =~ s/\n//g