in reply to Re: Showing pop-up window after x-seconds processing
in thread Showing pop-up window after x-seconds processing
Thank you. Your method "Modifying your data import loop" works great. I noticed now, that much of the importing time in my script is due to a "sort" I must due during importing. Any way to keep track also of this time? What I have so far is following (after implementig your idea):
sub import { $dbh = DBI->connect( "dbi:SQLite:files/database/data3.db" ) || die "Ca +nnot connect: $DBI::errstr"; my $start_time = time(); # remember when we started foreach my $row_db ( sort { deaccent($a->[($selected_order+2)]) cmp de +accent($b->[($selected_order+2)]) or $a->[($selected_order+2)] cmp $b +->[($selected_order+2)] } @$all_select_glossary_orderd ) { my ($ID, $a, $b,$c, $d, $e, $f) = @$row_db; ### DOING HERE SOMETIHN WITH MY DATA (IMPORT/PRINTING) if (time - $start_time > 2) { # 2 seconds have passed display_note(); $mw->update(); } } $dbh->disconnect; } #subrutine for better alphab. sorting sub deaccent { my $in = $_[0]; return lc($in) unless ( $in =~ y/\xC0-\xFF// ); #short circuit if +no upper chars # translterate what we can (for speed) $in =~ tr/ÀÁÂÃÄÅàáâãäåÇçÈÉÊËèéêëÌÍÎÏìíîïÒÓÔÕÖØòóôõöøÑñÙÚÛÜùúûüÝÿý/ +AAAAAAaaaaaaCcEEEEeeeeIIIIiiiiOOOOOOooooooNnUUUUuuuuYyy/; # and substitute the rest #my %trans = qw(Æ AE æ ae Þ TH þ th Ð TH ð th ß ss); #$in =~ s/([ÆæÞþÐðß])/$trans{$1}/g; $in =~ tr/'//d; # d for delete return lc($in); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Showing pop-up window after x-seconds processing
by Corion (Patriarch) on Aug 08, 2010 at 08:26 UTC |