Click here to get back home

how to force scalar context

 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 force scalar context Stuart Kendrick 07-12-2004
Posted by Stuart Kendrick on July 12, 2004, 12:07 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 Paul Lalli on July 12, 2004, 3:19 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
list vs scalar context for localtime? October 25, 2004, 3:48 pm
file glob in scalar context March 29, 2006, 10:56 am
WHY are args for sprintf in scalar context? October 31, 2007, 9:25 am
scalar context for testing arguments March 6, 2008, 11:10 am
substr forces scalar context with array argument November 29, 2005, 7:18 am
Why isn't void context a 'real' context December 11, 2007, 4:15 pm
List context versus list context June 21, 2006, 4:18 pm
Replace scalar in another scalar January 27, 2005, 3:21 pm
force IV to NV November 6, 2006, 6:45 pm
Trying to force 32-bit in pack() October 12, 2004, 5:19 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap