Click here to get back home

deleting empty lines from a variable containing \n's

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
deleting empty lines from a variable containing \n's machoq 11-03-2004
Get Chitika Premium
Posted by machoq on November 3, 2004, 3:59 pm
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Similar ThreadsPosted
Re: Ignore empty lines and ones that start w/... April 16, 2008, 2:10 am
Re: Ignore empty lines and ones that start w/... April 16, 2008, 4:48 am
How to filter out lines from a variable that has multi-lines? September 28, 2007, 9:09 pm
variable with empty space August 22, 2006, 2:20 pm
Testing on empty variable February 9, 2008, 2:39 pm
how match/expose the value in an empty variable having length of 1 July 15, 2006, 2:49 am
Multiple lines of html store in variable non messy way January 5, 2005, 9:56 am
deleting from stash April 3, 2007, 9:44 am
Deleting files June 2, 2007, 1:46 pm
Deleting characters from the end of each line September 21, 2006, 10:12 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap