sub component_window { my ($prch,$pid) = @_; ... my $tail = Tk::IO->new( -linecommand => sub { tail_lines($prch, $_[0]) }); ... } sub tail_lines { my ($proc,$text) = @_; ... }