Hi to all,
I have to do a software with tk::table interface
for real time check, the problem is that the tk::table
to every call it occupies new memory RAM. After some time the software crash. This example is generic, but display in simple mode the system. Any help is appreciated, in order to obtain a
stable software.
#!perl
use strict;
use Tk; use LWP::Simple; #die "usage: $0 SYM1 SYM2 SYM3" if !@ARGV; @ARGV = ("msft","intc"); my @kk1 = ("","","","",""); my $URL = "http://quote.yahoo.com/d/quotes.csv?s=" . join('+', @ARGV) . "&f=sl1d1t1c1ohgv&e=.csv"; require Tk::Table;
my $mw = MainWindow->new; $mw->title("QuoteView"); my $upLab = $mw->Label(-width => 20, -height => 1, -text => "Waiting...")->pack; my $table = $mw->Table(-rows => @ARGV + 1, -columns => 5)->pack; for (1..5) { $table->put(1, $_, (qw(SYMBOL QUOTE CHANGE HIGH LOW))[$_-1]); } GetQuotes(); $mw->repeat(15000, sub {eval {GetQuotes()}; print $@ if $@;}); MainLoop; sub GetQuotes {
my $c = get($URL); last unless $c; my $row = 1; foreach my $line (split /^/m, $c) { chomp $line; $line =~ /"(.+?)",(.*?),.*?,.*?,(.*?),.*?,(.*?),(.*?),/; no strict 'refs'; for (1..5) { $table->put($row+1,$_,${$_}); }; use strict 'refs'; $upLab->configure(-text => "" . localtime()); $row++; } } p.s.
Deallocation of memory not go with
($table->destroy and $table->packForgot).
Thanks in advance, Stefano |