in reply to
Formatting text-Create table -perl Tk
You can try the format method. See perldoc format.
#!/usr/bin/perl
my $foo = '';
open FH, '+>', \$foo or die $!;
format FH_TOP =
WHO COMMAND OUTPUT
USER TERMINAL DATE & TIME LOCATION
-----------------------------------------------------------
.
my @who_output= `who`;
foreach my $line (@who_output) {
my ($userid,$terminal,$month,$day,$time,$location) = split(/\s+/,$line
+);
chomp $location;
format FH =
@<<<<<<< @<<<<<<<<< @<<< @<< @<<<<< @<<<<<<<<<<<<
$userid $terminal $month $day $time $location
.
write FH;
}
#print "$foo\n";
use Tk;
my $top = new MainWindow;
my $txt = $top->Scrolled("Text")->pack;
$txt->insert('end', "$foo\n") ;
MainLoop;