I have a Perl/Tk program running under Windows that wants
to spawn a copy of excel. Running `start file.csv` with backticks is usually
the easiest way to do it, but with the Tk event loop running there's always a 30 second delay until the subprocess starts up. Task manager doesn't show any activity on the computer's part, and the backticks run quite snappily outside of Tk.
Anybody seen this before or have any ideas?
Here's a demo script. Use the menu option File/Report extract to see the pause. (Note that the window it opens is tiny, you might miss it on your screen).
use Tk;
use File::Spec;
$top = MainWindow->new();
my $menubar = $top->Menu(-type => 'menubar');
$top->configure(-menu => $menubar);
my $filemenu = $menubar->cascade(-label => '~File', -tearoff => 0);
$filemenu->command(-label => '~Report extract',
-command => [\&report_extract],
);
$filemenu->command(-label => 'E~xit',
-command => [sub {exit}],
);
print STDERR "there's a tiny window open, it's small but it's there\n"
+;
MainLoop();
sub report_extract {
my $tmpdir = File::Spec->tmpdir();
open (F, ">$tmpdir\\xx.csv") || die $!;
print F "aaa,bbb,ccc\nddd,eee,fff\n";
close F;
my $cmd = "start $tmpdir\\xx.csv";
print STDERR "running $cmd\n";
`$cmd`;
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.