Click here to get back home

Replace scalar in another scalar

 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
Replace scalar in another scalar Mark 01-27-2005
Get Chitika Premium
Posted by Mark on January 27, 2005, 3:36 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 Arndt Jonasson on January 27, 2005, 4:48 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
How does a scalar know what it is? July 24, 2005, 2:16 am
I Broke a scalar August 25, 2004, 10:43 pm
Re: I Broke a scalar August 25, 2004, 11:13 pm
Loop through scalar? September 28, 2004, 1:02 am
reading a zip from an IO::Scalar in 5.8 October 13, 2004, 10:54 pm
IO::Scalar insanity March 1, 2005, 8:54 pm
List and scalar OOE October 17, 2005, 12:25 pm
Using scalar instead of stream January 21, 2006, 7:19 am
scalar to method name September 10, 2006, 2:02 am
How can I name my scalar with a for loop? December 12, 2007, 3:32 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap