Click here to get back home

Learning PERL for a new beginner

 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
Learning PERL for a new beginner Lisa Horton 02-04-2005
Posted by Lisa Horton on February 4, 2005, 1:18 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 Sherm Pendley on February 4, 2005, 6:44 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
A Perl Beginner March 19, 2007, 10:39 am
Beginner: Installing Perl Program May 16, 2005, 3:05 pm
Beginner asks How to install cpan module to Perl installed on WinXP? September 14, 2005, 8:26 am
Learning Perl September 24, 2005, 4:34 pm
Learning PERL November 9, 2005, 8:07 pm
Learning Perl June 12, 2008, 12:52 pm
Which is the best book for learning OO perl? October 25, 2004, 10:11 pm
Which is the best book for learning OO perl? October 25, 2004, 10:13 pm
learning perl - the book December 31, 2004, 1:22 pm
"Learning Perl" book July 13, 2006, 6:43 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap