I have the following code which pings some wireless access points. Im still writing it but Im looking for a way to update the text as each access point is pinged instead of after its done pinging them all. Any help is appreciated.
#!/usr/bin/perl use Net::Ping; use Tk; use Tk::Dialog; my $mw; my $shift; my $port; my @Addr=( 1 ... 55 ); my $statbar; $mw = MainWindow->new; $mw->title("AP ping"); $mw->geometry("203x595"); $mw->Label(-text => 'Choose Access Point to Ping')->place(-x => 5, -y +=> 5); $statBar = $mw->Label(-text => '', -font => [-family => 'Lucida Console +', -size => 8], -width => 28, -relief => 'groove')->place(-x => 0, - +y => 575); $mw->Button(-text => "Get Status", -relief => 'groove', -command => sub { $statBar->configure(-text => "pinging $h +ost"); if ( $host eq "All" ) { \&mstat($_) for +( 1 .. scalar(@Addr)) } else { \&mstat($host); } })->place(-x => + 60, -y => 70); $mw->Button(-text => "Exit", -relief => 'groove', -command => sub { exit })->place(-x => 172, -y => 70); my $tagOM = $mw->Optionmenu(-variable => \$host, -options => [ '', 'All', @Addr ], -width => 25, -relief => 'groove', -command => sub {})->place(-x => 5, -y => 30 +); my $statLog = $mw->Scrolled("Text", -scrollbars => 'e', -height => 30, + width=> 25)->place(-x => 0, -y => 130); MainLoop; ############# sub mstat ############# { $ap = shift; my $host = sprintf ("192.9.210.1%02d", $ap); my $p = Net::Ping->new(); if ( $p->ping($host)) { $statLog->insert('end', "AP $host is up\n"); #$statBar->configure(-text => "pinging $host is up"); } else { $statLog->insert('end', "AP $host is down\n"); #$statBar->configure(-text => "AP $host is down") } $p->close(); }

Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson

In reply to perl/Tk and realtime update of output by tcf03

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.