On 26/07/07, Marc Nürnberger <[EMAIL PROTECTED]> wrote:
Hmmmm... I found a strange behavior after adding some "debugging" prints. The delay occurs when the last command is executed. That `links.html` one. Everything works fine up to that point. But that's only the case when I use the GUI version. When using the console version that command runs without delay. Does somebody know why that occurs?
I have no idea what might be causing that. I can't immediately see how Win32::GUI could be at fault, but I am never surprised. I , personally, wouldn't use back-ticks to launch my browser with a page. It's the wrong construct (it's designed to capture the stdout of a program into a perl variable), and relies on your windows box having particular registry entries - it certainly doesn't work for em here. I tried using system "start temp.html"; instead, and I see the delay you're taking about. I can get rid of the delay by doing undef $main; before making the system call (my code below). I'm afraid that I don't have time to look into this further right now. (but can you post back with the output of 'perl -v' and which windows OS you're using, and I'll try to look at it another time. As an aside, if you want to extract links from HTML pages, you'd do well to look HTML::LinkExtor, which is a full HTML parser designed to do just this - you'll find that using regexes is not going to give you the results you ant in the long term (for example you code won't work if a link is split across more than one line). The docs for HTML::LinkExtor have a nice example that shows how you can cope with large files without having to use the intermediate temporary file that you are using. Regards, Rob. #!perl -w #use strict; #use warnings; use LWP::UserAgent; use Win32::GUI(); # Creation of the LWP Useragent with the Firefox Cookie file my $ua = LWP::UserAgent->new; # Creation of the GUI my $main = Win32::GUI::Window->new( -title => 'Link Filter', -size => [295, 161], -maximizebox => 0, -resizable => 0, ); $main->AddLabel( -pos => [4,4], -size => [100,17], -text => 'Bitte URL eingeben:', ); $main->AddTextfield( -name => 'tfURL', -pos => [4,20], -size => [281, 77], -multiline => 1, ); $main->AddButton( -name => 'btGet', -pos => [5, 100], -size => [279,33], -text => 'Get Them!', ); $main->Center(); $main->Show(); Win32::GUI::Dialog(); $main->Hide(); sub btGet_Click { return -1; } my $url = $main->tfURL->Text(); undef $main; # comment out this line to see the delay # Get the content of the Website and save it into a temporary HTML file $ua->get($url, ':content_file' => 'temp.html'); system "start temp.html";