I was fooling around with perlTk and came up with this snippet. It might be handy for people writing gui programs like log checkers or wanting to use other unix program output.
UPDATED: it now uses the code enhancements liz suggested. Thanks liz ;)
#!/usr/bin/perl #sambastatus in PerlTk use strict; use Tk; use Tk::HList; my $user=0; my $top = new MainWindow(-title => 'Samba TK sample'); my $hlist = $top->Scrolled("HList", -header => 1, -columns => 7, -scrollbars => 'osoe', -width => 80, -selectbackground => 'SeaGreen3', )->pack(-expand => 1, -fill => 'both'); #updated with liz example! my $option = 0; foreach (qw(user gid pid machine service ip-adres logon)) { $hlist->header('create', $option++, -text => $_); } open SMBST, "smbstatus |grep \)|"; #filters out the nonsense while(<SMBST>){ (my $service,my $uid,my $gid,my $pid,my $machine,my $ipadres,my $rest) + = split /\s+/, $_, 7; chomp $rest; $hlist->add($user); $hlist->itemCreate($user, 0, -text => "$uid"); $hlist->itemCreate($user, 1, -text => "$gid"); $hlist->itemCreate($user, 2, -text => "$pid"); $hlist->itemCreate($user, 3, -text => "$machine"); $hlist->itemCreate($user, 4, -text => "$service"); $hlist->itemCreate($user, 5, -text => "$ipadres"); $hlist->itemCreate($user, 6, -text => "$rest"); $user++; } close SMBST; MainLoop;

In reply to perlTk sample that shows sambastatus by teabag

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.