On Nov 1, 6:57 am, [EMAIL PROTECTED] (John W. Krahn) wrote: > slow_leaner wrote: > > On Oct 31, 10:27 am, [EMAIL PROTECTED] (Slow_leaner) wrote: > > >> Is there a way I can marge FILE2 into FILE1 or reverse together > >> without creating a new merge file. I am not sure there are a better > >> way to do it. If you give me some hint or help, i would appreciate > >> it. > >> thx. > >> Here is my code. > > >> #!/bin/usr/perl > > >> open(FILE1, /usr/test1.txt); > >> @temp =<FILE1>; > >> close (FILE1); > > >> open(FILE2, /usr/test2.txt); > >> @temp =<FILE2>; > >> close (FILE2); > > > 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 > > 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
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 $my_patterns = qr { BPDU|FAN_FAIL|ERROR|his }; @array_logs = qw( /mydocs/temp.txt /mydocs/temp2.txt /mydocs/temp3.txt ); for ( @array_logs){ open (IN, "$_") or die "can't open file $_"; while (<IN>){ if (/$my_patterns/){ print "$_"; } } close (IN); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/