Click here to get back home

How to read input data from pipe, file and files

 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
How to read input data from pipe, file and files maasha 07-09-2007
Get Chitika Premium
Posted by maasha on July 9, 2007, 2:58 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

Posted by Mumia W. on July 9, 2007, 8:03 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
Pipe input from a Text-File December 3, 2004, 6:30 am
Input - read file - return webpage January 6, 2005, 5:59 pm
Using an input/csv file to rename files July 26, 2006, 4:51 pm
Read xml file and write data to a txt file using PERL.... urgent April 17, 2007, 4:17 pm
read from file or from ? February 23, 2006, 9:11 am
Pipe input over several scripts January 18, 2008, 9:35 am
Can "perldoc" take input from a pipe? April 15, 2008, 1:05 pm
need server side script to read file/buffer data September 6, 2006, 7:45 pm
Read string from multiple files, output ordered by a 2nd file March 21, 2005, 4:51 pm
Unexpected Result From Pipe Read February 15, 2005, 12:01 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap