First, it's worth using strict and warnings.

Second, when you configure the text of the label in a loop, you literally do just that, ie you set the text of the label to the current value you assign to it.

If you want a multiline label, I'd join the individual lines together into a single string before printing it, like this:

#!/usr/bin/perl use Tk; use strict; use warnings; my $window = MainWindow->new; $window -> geometry("100x200"); $window->title("Host Report"); my $labs = $window->Label(-text => "Results", -wraplength => 100)->pac +k(-side => 'bottom'); #$window->Entry(-textvariable => \$hdb )->pack; $window->Button(-text => "Go", -command => \&host )->pack; $window->Button(-text => "Quit", -command => \&stop )->pack; MainLoop; sub host { my @message; #open (FH,"host.txt"); my @lines = <DATA>; #close FH; foreach my $hdb2 (@lines) { my @field = split(':',$hdb2); #if ($field[0] =~ /(?<![\w-])$hdb(?![\w-])/i) { push (@message, "$field[0] $field[1] $field[2]"); #} } my $messageString = join ('', @message); $labs->configure(-text =>"$messageString"); } sub stop{ exit; } __DATA__ these: lines are: the: lines that: you are: looking: at

Alternatively, you could use a widget other than a label, maybe something like this:

!/usr/bin/perl use strict; use warnings; use Tk; use Tk::ROText; my $hdb; my $window = MainWindow->new; $window->title("Host Report"); my $labs = $window->Scrolled('ROText')->pack(-side => 'bottom'); $labs -> Insert ("Results\n\n"); $window->Entry(-textvariable => \$hdb )->pack; $window->Button(-text => "Go", -command => \&host )->pack; $window->Button(-text => "Quit", -command => \&stop )->pack; MainLoop; sub host { #open (FH, "<", "host.txt"); my @lines = <DATA>; print STDERR "@lines\n\n"; #close FH; foreach my $hdb2 (@lines) { my @field = split(':',$hdb2); #if ($field[0] =~ /(?<![\w-])$hdb(?![\w-])/i) { $labs->Insert("$field[0] $field[1] $field[2]"); #} } } sub stop{ exit; } __DATA__ these: lines are: the: lines that: you are: looking: at

I hope that's helpful


In reply to Re: Multiple Rows by mtmcc
in thread Multiple Rows by PilotinControl

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.