Click here to get back home

Perl's GUI

 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
Perl's GUI Davy 08-26-2006
|--> Re: Perl's GUI Robert Hicks08-26-2006
Get Chitika Premium
Posted by zentara on August 27, 2006, 9:02 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 zentara on August 27, 2006, 10:34 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 Justin C on August 27, 2006, 12:50 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 Michele Dondi on August 27, 2006, 2: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

Posted by zentara on August 28, 2006, 8:23 am
Please log in for more thread options
wrote:

>wrote:
>
>>A few other comparisons bewtween Tk and Gtk2 (and WxWidgets built on
>>Gtk2).
>
>On an OT basis and on behalf of a friend of mine[*]: he's been having
>difficulties using threads with Tk. I don't have experience with
>either so I couldn't really help him, but from posts both here and on
>PM I already knew about the possible issues, so I just reminded him of
>good ol' fork(). Now the question is: is Gtk2 thread safe? Which
>toolkit is, if any?

>Michele

Well that is one of the good points about Gtk2 which I did not list.

It does have a "thread-safety mechanism", which appeared releatively
recently, around the 2.8 series of modules. Although it isn't perfect,
it does show that the Gtk2 developers are aware of the problems and
power of threads.


What it does, is allow you to set ( see the thread_usage.pl in the
examples subdir of the Perl/Gtk2 distro).

use Gtk2 qw/-init -threads-init 1.050/;
die "Glib::Object thread safetly failed"
unless Glib::Object->set_threadsafe (TRUE);

then in your threads, in the actual thread code block, you
can do things like below, where you use enter and leave,
to tell the main Gtk2 code that you are dipping into the thread and
are going to modify a widget in the main thread.

Gtk2::Gdk::Threads->enter;
$progress->set_fraction ($i);
$progress->set_text ($i * 100 .'%');
Gtk2::Gdk::Threads->leave;
# we're state employee's, so let's do some 'work'...
sleep $sleep;


This is a great advance, and similar code in Tk will result
in the dreaded "free to wrong pool error" or a segfault.

But as QoS pointed out, with proper precautions, threads can be
successfully used with a main thread containing Tk code, but it is
kind of a hack.

So yes, Gtk2 is thread-safe (with some limitations). I've tested this
quite a bit, and the Gtk2 thread-safety mechanism CAN be very finicky,
but it's a start.



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html

Similar ThreadsPosted
FAQ 5.4 How can I use Perl's "-i" option from within a program? January 26, 2005, 6:03 am
Perl's strengths: How well does Python do them? February 7, 2005, 3:03 pm
FAQ 5.4 How can I use Perl's "-i" option from within a program? April 10, 2005, 11:03 am
FAQ 5.4 How can I use Perl's "-i" option from within a program? June 26, 2005, 5:03 am
FAQ 5.4 How can I use Perl's "-i" option from within a program? September 4, 2005, 4:03 pm
FAQ 5.4 How can I use Perl's "-i" option from within a program? November 17, 2005, 5:03 pm
FAQ 5.4 How can I use Perl's "-i" option from within a program? February 2, 2006, 12:03 pm
FAQ 5.4 How can I use Perl's "-i" option from within a program? March 17, 2006, 3:03 am
FAQ 5.4 How can I use Perl's "-i" option from within a program? April 23, 2006, 3:03 am
Using tee with Perl's system command June 10, 2006, 10:23 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap