slow_leaner wrote:

On Nov 1, 6:57 am, [EMAIL PROTECTED] (John W. Krahn) wrote:

slow_leaner wrote:

Let me just add this to be clear.
I am so beginner, almost 4 moths, and not getting anywhere with perl.
I need some fire in my heart to keep me going. I just want someone to
show me how to fish but not to give me a fish. So all experts out
there please give me some hint.
this is what I would like to do.
I know how to read one file into array. BUT
1. I would like to merge 2 logs file into array lets called
@array_of_logs. I might be add more logs file into this array later.
So that i can just type the another log file in to array without
writing another open close code.  # my most difficult part.

my @array_of_logs = do {
     local @ARGV = (
         '/usr/test1.txt',
         '/usr/test2.txt',
         );
     <>
     };

2. matching the pattern that i have in array called  @matching_list =
qr(a|b|test|go\thome|)      #know how to match.

my @matching_list = grep /go\thome|test|[ab]|/, @array_of_logs;

3. email it to me if match any. (not sure what man page i should be
reading for)

perldoc Email::Send
perldoc Mail::Send
perldoc Net::SMTP

thanks for your reply and help Dr Ruud and John.
I am still reading about send mail in perl. but so far here is my
code.

#!/usr/bin/perl -w

#!/usr/bin/perl
use warnings;
use strict;

$my_patterns = qr { BPDU|FAN_FAIL|ERROR|his };

That matches either ' BPDU' or 'FAN_FAIL' or 'ERROR' or 'his '. Are you sure that you don't need to anchor that pattern at either end?

@array_logs = qw( /mydocs/temp.txt
                               /mydocs/temp2.txt
                               /mydocs/temp3.txt
                              );
for ( @array_logs){
 open (IN, "$_") or die "can't open file $_";

perldoc -q quoting

You should also include the $! variable in the error message so you know *why* it failed.

 while (<IN>){
  if (/$my_patterns/){
   print "$_";

perldoc -q quoting

  }
 }
 close (IN);
}



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to