On Sun, 2003-11-16 at 16:52, Rob Dixon wrote:
> Hi Sander. First of all, I guess this will feel like I'm ripping
> your code apart. Try to imagine me as your best-friend
> cardboard-cutout programmer with nothing but your interests
> at heart. :)

I'll do my best to see you as my best-friend, while you strip my 1st
code ;)
But thanx (also to the pther ppl) for pointing me to some things.




> Few people know what to make of Perl the first time they see
> it. People try to force it into either C or shell, but it's
> neither. Take a look at what I've written below, and keep an
> open mind!
> 
It's hard to start (as always), but it will work...some day :)
I have some knowledge about the shell and linux, but i don't write code
in any other language, so it's all new to me.


> 
>   use strict;   # Always
>   use warnings; # Usually (same as -w qualifier but portable)

i will do that, "use warnings;" gave me more (human readable) errors, so
better to understand for me.

I was looking for the > and < operators. I had used them with backticks
(but gave a error message, because it was a "greater then" value,
because i left spaces like print $a > $b instead of print $a>$b .... 
But now... i want to be more precise with my script.
So i made 2 extra if loops, 1 is looking for errors, and if so, also
check if there is no 127.0.0.x adres in it anymore (works so far :D)
then i want to sort the ip's ....and that's what dazzling me now...
This is what i want: I Look in the (newly) written error.log, and see
immediatley that someone with ip 123.45.6.7 has tried 1x to login. But
123.45.6.8 has tried to login 50x in the last 6 days... 
Now my thought was that i made an array to put everything from while
<ER>, and when it's an error message and *not* 127.0.0.x in the array,
then sort, and put it in the error.log.... unfortunatly it's not
working.... so i looked for the subroutines in Learning Perl... but i
don't get it *how* you can get these values....
                
Thanx a lot

Sander 


#!/usr/bin/perl
use strict;
use warnings;
open (ER, "</home/unicorn/Plscripts/error_log") || die "can't open ER,
$!\n"; #opening error_log for ReadNow all the advice helped me out,
open (EL, ">>/home/unicorn/Plscripts/error.log") || die "can't open EL,
$!\n"; #opening ERROR.LOG for Write

while (<ER>) {  #as long as ER is open, read....
       if (/error/)  {  #if there is any errormessage in the file
                if (!/127.0.0.*/) {  #and it's not local 127.0.0.x
                @sorted_list = sort by_ip (ER) ;        #the inputfile is sorted by ip 
in
@sorted_list
                print EL $_;            #print output to ERROR.LOG #was print EL $_;
                }
        }
}
#sub by_ip {
#       @sorted_list = sort { $a <=> $b } EL;
#       }


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to