Click here to get back home

file glob in 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
file glob in scalar context nan li 03-29-2006
Posted by Kraven on March 29, 2006, 11:20 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 George on March 29, 2006, 11:51 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
how to force scalar context July 12, 2004, 12:07 pm
list vs scalar context for localtime? October 25, 2004, 3:48 pm
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
Scalar variable in void context before a loop October 20, 2008, 1:49 am
substr forces scalar context with array argument November 29, 2005, 7:18 am
File::Glob - can it recurse? August 6, 2004, 9:39 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

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap