Click here to get back home

Defining a string/array with perl characters

 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
Defining a string/array with perl characters Duke of Hazard 09-27-2004
Get Chitika Premium
Posted by Duke of Hazard on September 27, 2004, 8:10 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 Bob Walton on September 27, 2004, 11:40 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
[perl-python] 20050116 defining a function January 16, 2005, 7:45 am
Defining 3D array September 17, 2004, 9:06 pm
Error when using a defining a new module April 3, 2007, 8:25 am
Adding a delimiter inbetween number characters and letter characters January 12, 2005, 9:25 am
Print Spanish characters in Perl? June 20, 2008, 12:03 am
Perl returning mucky characters to a shell August 2, 2004, 3:20 pm
can Perl detect / match unicode characters October 22, 2006, 1:54 pm
print cyriilic (UTF-8) characters with PERL on HTML page September 13, 2006, 4:59 am
count lines,words,punctuations and characters in perl script November 11, 2006, 9:50 am
what to do with special characters like "é","ë",... November 11, 2004, 5:14 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap