Click here to get back home

write to stdout and another file at the same time.

 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
write to stdout and another file at the same time. akbari_n 06-03-2005
Get Chitika Premium
Posted by akbari_n on June 3, 2005, 6:21 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 John W. Krahn on June 4, 2005, 2:12 am
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
Compare UNIX file time with time in a variable November 23, 2006, 2:39 pm
copy stdout fails with permission denied when stdout is redirected December 7, 2005, 1:15 pm
Redirecting STDOUT to a file April 25, 2006, 12:53 pm
Printing to a file Or STDOUT August 21, 2006, 4:35 am
splitting stderr/stdout without using file April 27, 2006, 7:22 am
sending output to STDOUT or a file April 22, 2008, 2:26 pm
Read xml file and write data to a txt file using PERL.... urgent April 17, 2007, 4:17 pm
How to read and write a file without open file twice? Thanks in advance. September 25, 2007, 2:31 pm
Can Perl redirect STDOUT to file AND to command window? November 29, 2005, 2:02 pm
GMT time to local time, according to timezone and summer/winter time. May 15, 2005, 10:45 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap