Click here to get back home

words selection

 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
words selection Truty 09-02-2006
Get Chitika Premium
Posted by Truty on September 2, 2006, 10:42 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 David Squire on September 2, 2006, 11:04 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 Truty on September 2, 2006, 11:14 am
Please log in for more thread options
Thanks David,


I try to select more code for help me but I can't to copy and paste all
code.

Wait ... ;)



Posted by David Squire on September 2, 2006, 11:17 am
Please log in for more thread options
Truty wrote:
> Thanks David,
>
>
> I try to select more code for help me but I can't to copy and paste all
> code.


Please quote context when you reply. See the posting guidelines for this
group, which are posted here regularly.


DS

Posted by David Squire on September 2, 2006, 11:48 am
Please log in for more thread options
David Squire wrote:
> Truty wrote:

[snip]

>> if (($ligne =~ \[$carac_available]\) && ($ligne !~
>> \[$carac_notavailable]\) ) { print $ligne." | "; }

[snip]

> This will not even compile. You can't use backslashes as regex
> delimiters. The compiler should have told you that.

Clarification: you can't use backslashes as the delimiters without an
operator such as "m" being used at the start, e.g.

if (($ligne =~ /[$carac_available]/) && ($ligne !~
/[$carac_notavailable]/) ) { print $ligne." | "; }

is OK, and so is

if (($ligne =~ m\[$carac_available]\]) && ($ligne !~
m\[$carac_notavailable]\) ) { print $ligne." | "; }


DS


Similar ThreadsPosted
Checkbutton - multiple selection December 15, 2006, 9:44 pm
Mechanize question: how to make a special selection ? September 9, 2005, 6:01 pm
Gtk2-Perl!How to change color of the selection bar in widget Gtk2::SimpleList? December 3, 2007, 1:16 pm
Quotes around words January 25, 2008, 3:52 am
Words to numbers September 25, 2008, 6:20 pm
Words to numbers September 25, 2008, 6:24 pm
extract words from string July 14, 2004, 4:38 pm
Fun problem: Overlapping words November 12, 2004, 6:12 pm
Cut the last invisible spaces from the words November 25, 2004, 5:22 pm
counting words in a file November 26, 2004, 7:27 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap