Acid Amygdala has asked for the wisdom of the Perl Monks concerning the following question:

I have been working with this code for quite some time now, and I decided to attempt to implement File::Tail. This code reads a log file and creates popups using the information from it. I am having trouble with the placement of "Win32::GUI::Dialog()" so that the windows can be interactive. I have tried to place this in the spots labeled 1, 2 and 3, but with no luck. If it is placed in 2 or 3, no information shows up in the popup windows and it is not interactive. If put in 1, information shows but the window is only interactive when new windows are being created. I know this may sound like a stupid question, and that I am only a beginner, but I just can't seem to find the right placement for this crucial piece of code. Any help would be gratefully appreciated from you wise monks. Thanks.
use warnings; use File::Tail; use Win32::GUI(); use Win32::Sound; @alert = ['a'..'z']; $i=0; $p=1; my $line; my $filename = "log3.txt"; my $file=File::Tail->new(name=>$filename); while (defined($line=$file->read)) { if($line=~ /(\s+)(\d{1,4})(\.\d{1,4}){3}(\s+)/) { &Build_Window; ++$i; ++$p; #1 } } #2 sub Build_Window { if($i==50){ $p=1; $i=0;} $datetime = localtime(); $alert[$i] = new Win32::GUI::Window(-name => "Alert", -width = +> 500, -height => 150, -pos => [$p*10, $p*10]); $font = Win32::GUI::Font -> new(-name => "Arial", size => 46, +-bold => 1); $alert[$i] -> AddLabel(-text => $datetime, -font => $font); $alert[$i] -> AddLabel(-text => "SNORT ALERT: MALICIOUS BEHAVI +OR DETECTED!", -font => $font, -top => 50); $alert[$i] -> AddLabel(-text => $line, -font => $font, -top => + 75); my $t1 = $alert[$i] -> AddTimer('T1', 1000); #Win32::Sound::Play("SystemExclamation"); $alert[$i] -> Show(); #3 sub T1_Timer { return -1; } sub Alert_Terminate { return 1; } }

Replies are listed 'Best First'.
Re: File::Tail with GUI
by Acid Amygdala (Novice) on Feb 28, 2009 at 23:21 UTC
    From what I can gather, the line "Win32::GUI::Dialog()" should be at the spot labeled 2, however, I keep getting errors. Not only does it not show any information in the windows, but it also give me an error saying "Perl Command Line Interpreter is not responding" and gives me a choice to close the program or wait for it to respond. Can anyone give me advice, explain my problem or point me in the right direction (websites or something) that can help me fix the problem?
      Just use Win32::GUI::MessageBox intead. Why create a full window with dialog just for an alert?
        Although a Message Box would work with File::Tail, it will not work for this because I need more than one alert up at one time.
      I took a look at the Event Viewer, and the Problem Reports and Solutions, and here is what I found:
      Description A problem caused this program to stop interacting with Windows. Problem signature Problem Event Name: AppHangB1 Application Name: perl.exe Application Version: 5.10.0.1004 Application Timestamp: 48bef0d8 Hang Signature: 6b71 Hang Type: 0 OS Version: 6.0.6000.2.0.0.768.3
      Does anyone have any ideas about why it hangs perl.exe or how to fix it? Thanks.