in reply to Re^4: Win32 GUI Window Problem
in thread Win32 GUI Window Problem

You'd get better responses if your code showed some semblence of effort. A few questions:

  1. Why are you initialising @alerts with an anonymous array containing the characters 'a'..'z'?
  2. Why do you have two subroutines embedded within a subroutine?
  3. What it sub T1_Timer() meant to achieve?
  4. Why aren't you using strict?
  5. How is sub Loop() ever meant to be run?
  6. Why are you closing the file twice?
  7. Why do you then reopen it for output and never close it?

Anyway, try this:

#! perl -slw use strict; use Win32::GUI(); use Win32::Sound; my $filename="yourfile.dat"; open(TXT, $filename)||die("Could not open file!"); my @filedata = <TXT>; close(TXT); my( $running, @alerts ) = 0; my $p = 100; for my $element ( @filedata ) { if( $element =~ /(\s+)(\d{1,4})(\.\d{1,4}){3}(\s+)/) { push @alerts, Build_Window( $element, $p += 10 ); ++$running; } } sub Alert_Terminate { return --$running ? 1 : -1; } sub Build_Window { my( $element, $pos ) = @_; my $win = new Win32::GUI::Window( -name => "Alert", -width => 500, -height => 150, -pos => [ $pos, $pos ] ); my $font = Win32::GUI::Font->new( -name => "Arial", size => 46, -bold => 1 ); $win->AddLabel(-text => localtime(), -font => $font); $win->AddLabel( -text => "SNORT ALERT: MALICIOUS BEHAVIOR DETECTED!", -font => $font, -top => 50 ); $win->AddLabel(-text => $element, -font => $font, -top => 75); Win32::Sound::Play("SystemExclamation"); $win->Show(); return $win; } Win32::GUI::Dialog();

But be aware, your apparent lack of understanding, and of effort to understand, means that you are going to have to start reading some documentation, and try to develop your understanding by writing a few simple (non-GUI) programs, before you will get further help from me.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^6: Win32 GUI Window Problem
by Acid Amygdala (Novice) on Feb 09, 2009 at 21:47 UTC
    Thank you once again BrowserUk, I think I can do this on my own now. I realize now that although I tried to understand, my attempts are not up to par with perlmonks users, so I'm going to go get this fixed on my own no matter how long it takes. Like they say, you just gotta keep at it. But I appreciate all of the help that perlmonks users have offered me. Hasta luego, PerlMonks, and happy coding.
      so I'm going to go get this fixed on my own no matter how long it takes.

      No! You do not have to do it on your own. You are exactly what this place is all about!

      I, and most of the other monks, are only too willing to help you. But, you have to show that you are trying to help yourself.

      For example, did you try the code I posted? What happened? Did you try and answer the questions I asked?

      Making random changes to programs rarely makes them work. Many of your errors would be caught if you added use strict;<c> and <c>use warnings; at the top of your program. Switching them off just ingnores the problems, it does fix them.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I am adding "use strict", and working out those issues, i have "use warnings" and "use diagnostics" for in-depth error checking, and I have answered most of the questions. The code you gave me did work, doing almost what I needed to do. I need multiple windows up at once instead of one at a time (because someone won't always be there to check the windows). That is what the array of characters is for (because I have no idea how to begin an infinite array or if that is even possible)and each new window needs a name. The timer is for returning -1 so each window can come up (otherwise I only get one window at a time). I figured out the open/close of the text file was a copy/paste error of mine, so fixed that. Right now I decided to go through the code you provided, dissect it and learn about the parts that I don't understand. So that is my current task. Then I can apply my new knowledge to my own code.