Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > How to match carriage returns and line feeds

Reply
Thread Tools

How to match carriage returns and line feeds

 
 
Schroeder
Guest
Posts: n/a
 
      01-26-2005
I am using ActiveState's Perl on Windows and am trying to remove an excess
\x0d character I am getting (not sure why I am getting it, but doesn't
matter if I can easily be rid of it). What I see in my text is sequences of
\x0d\x0d\x0a - and I am trying to replace them with simply CRLF (\x0d\x0a).
I admit to being a newbie to Perl, so maybe I am just missing something.
Why wont the following work:

$text =~ s/\x0d\x0d\x0a/\x0d\x0a/gs;

Thanks

--Jeff--


 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      01-26-2005
In article <LtPJd.28135$(E-Mail Removed)> ,
Schroeder <(E-Mail Removed)> wrote:

> I am using ActiveState's Perl on Windows and am trying to remove an excess
> \x0d character I am getting (not sure why I am getting it, but doesn't
> matter if I can easily be rid of it). What I see in my text is sequences of
> \x0d\x0d\x0a - and I am trying to replace them with simply CRLF (\x0d\x0a).
> I admit to being a newbie to Perl, so maybe I am just missing something.
> Why wont the following work:
>
> $text =~ s/\x0d\x0d\x0a/\x0d\x0a/gs;


It works for me:

#!/usr/local/bin/perl
#
use strict;
use warnings;

my $text = "abc\x0d\x0d\x0adef";
p("Before",$text);
$text =~ s/\x0d\x0d\x0a/\x0d\x0a/gs;
p('After',$text);
sub p
{
my($title,$text) = @_;
print "\n$title:\ntext=<$text>\n";
print join(' ',map { ord $_ } split(//,$text)),"\n";
}


__OUTPUT__
Before:
text=<abc
def>
97 98 99 13 13 10 100 101 102

After:
text=<abc
def>
97 98 99 13 10 100 101 102

You need to post a short program demonstrating the problem you are
having.

FYI; this newsgroup is defunct. Try comp.lang.perl.misc in the future.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keeping text control characters (line breaks / carriage returns) in DetailsView field Bazza Formez ASP .Net 2 08-06-2007 08:53 PM
How to display "No Rss feeds new availabe" when there are no FEEDS Patrick Olurotimi Ige ASP .Net 2 05-04-2005 11:50 PM
Applets: getParameter() stripping carriage-returns and line-feeds???? rrey2279@aol.com Java 3 01-17-2005 06:04 PM
Help: Delete a single carriage return in a file, but not a double carriage return? Steve Anderson Perl Misc 3 06-21-2004 12:48 AM
How to create carriage return or line feed or new line Dave Tichenor ASP .Net 3 02-17-2004 01:55 AM



Advertisments