Click here to get back home

perl pipe reading

 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
perl pipe reading lambelly 06-20-2005
Get Chitika Premium
Posted by lambelly on June 20, 2005, 4:55 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

Posted by J. Gleixner on June 20, 2005, 7:29 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
Reading from pipe with perl -na -e and detecting last line June 19, 2006, 10:03 am
How to open a pipe for reading and writing? November 5, 2004, 5:16 pm
reading from pipe, writing to a file June 1, 2006, 12:35 am
reading from pipe, writing to a file June 1, 2006, 12:35 am
reading from stdin via pipe, buffering? March 3, 2008, 3:20 am
perl PIPE - need an example of piping in June 9, 2005, 11:59 pm
Net::SSH::Perl - Broken Pipe February 26, 2007, 10:02 pm
pipe used in perl - as in unix sense October 23, 2005, 7:43 am
sending email from perl using a pipe and mailx April 18, 2008, 10:05 am
Perl "pipe" command, cant print binary to handle January 31, 2005, 12:05 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap