Juan,

It is difficult to read your code when it is not formatted for this website. Could you please wrap your code in code tags, like: <code></code>?

I have made an attempt to reconstruct your code from what you have provided. I think your code looks like this, but please verify:

Updated:
#!/usr/local/bin/perl # Program to check /var/log/messeges for alerts contining the word IDS + and send mails # in case the word is found- including the line use strict; use warnings; use Mail::Mailer; open (INFO, "/var/log/messages"); # Open the file while { @message = <INFO> / IDS/g # Read it into an array @message = $& $mailer = Mail::Mailer->new("smtp", "10.83.27.71"); $mailer->open( 'From' => 'Syslog <syslog@hpda.com.ar>', 'To' => 'gabriela pinado <gabriela.pinado@hpda.com.ar>', 'Subject' => 'PiX Detected Attack ' ); print $mailer <<@message; close($mailer) or die "can't close mailer: $!";

Here is my revised version:

#!/usr/local/bin/perl use strict; use warnings; use Mail::Mailer; my $mailer = Mail::Mailer->new("smtp", "10.83.27.71"); open (INFO, "/var/log/messages"); while (my $message = <INFO>) { next unless $message =~ / IDS/; $mailer->open( 'From' => 'Syslog <syslog@hpda.com.ar>', 'To' => 'gabriela pinado <gabriela.pinado@hpda.com.ar>', 'Subject' => 'PiX Detected Attack ' ); print $mailer $message; $mailer->close() or die "can't close mailer: $!"; } close INFO;

From what I can tell, I think this should have the desired result you are looking for.


Where do you want *them* to go today?

In reply to Re: pattern matching and sending mail! by thezip
in thread pattern matching and sending mail! by juanb007

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.