<?xml version="1.0" encoding="windows-1252"?>
<node id="247248" title="Re: Atomic operations in perl and Tk::IO" created="2003-04-01 10:03:28" updated="2005-06-04 05:13:02">
<type id="11">
note</type>
<author id="178658">
hiseldl</author>
<data>
<field name="doctext">
&lt;P&gt;Update: &lt;homer_simpson_voice&gt;DOH! cloooosures&lt;/homer_simpson_voice&gt;&lt;br /&gt;
-- I'll leave the text here so that no else who reads this makes the same mistake.  :-)
&lt;/P&gt;
&lt;P&gt;In your call to component_window(), you assign $pcrh and $pid a la
&lt;code&gt;    my ($prch,$pid) = @_;
&lt;/code&gt;
now, I don't see a shift nor a pop nor any other @_ manipulations, which makes your call to tail_lines() incorrect:
&lt;code&gt;sub component_window {
    my ($prch,$pid) = @_;
    ...
    my $tail = Tk::IO-&gt;new( 
       -linecommand =&gt; sub { tail_lines($prch, $_[0]) });
    ...
}

sub tail_lines {
    my ($proc,$text) = @_;
    ...
}&lt;/code&gt;
because &lt;code&gt;$_[0]&lt;/code&gt; is the same as &lt;code&gt;$prch&lt;/code&gt; when you call &lt;code&gt;tail_lines($prch, $_[0])&lt;/code&gt;, and this seems to be not what you want.
&lt;/P&gt;
&lt;P&gt;You should be able to either pass the third element directly or get the third element in a var at the top of your sub (i.e. 
&lt;code&gt;sub component_window {
    my ($prch,$pid,$text)=@_;
    ...&lt;/code&gt;
and pass that...
&lt;code&gt;    ...
    my $tail = Tk::IO-&gt;new( 
       -linecommand =&gt; sub { tail_lines($prch, $text) });
    ...
}
&lt;/code&gt;
&lt;/P&gt;


&lt;P&gt;--&lt;br/&gt;[hiseldl]&lt;br/&gt;What time is it? It's [190308|Camel Time!]&lt;/P&gt;</field>
<field name="root_node">
247232</field>
<field name="parent_node">
247232</field>
</data>
</node>
