my $t1 = $top->Label(-text=>"$host",-background => "$color")->pack();

Rather than repeatedly creating and pack-ing a new  Label widget into its parent as is now done, try re-configuring the options of an existing widget with  configure (see discussion of this method in Tk::options):
    $label_widget->configure(-text => $new_text, -background => $new_color);
(Again, this assumes the label widget has already been created and packed somewhere else in the code.)

BTW: It's not necessary to interpolate a scalar into a string (e.g.,  "$host" in the OPed code) in order to use it as a string.

Also BTW: I share your liking for Tk, all the more since I have some hard-won experience with it. But, sadly, it seems possible it may have become an orphan application. See various discussions on PerlMonks of Tk vis-a-vis Gtk2 and Wx.


In reply to Re: TK refresh widgit data by AnomalousMonk
in thread TK refresh widgit data by siffland

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.