Griggs Rob wrote:
> Hi Guys,
>
> The code below extracts an ip address from the /var/log/maillog file in
> the event of the line containing the words "reject=550". It works fine,
> but is there a way of shortening that regular expression?
>
> open(LOG,"/var/log/maillog");
>
> while(<LOG>) {
> chomp;
> if($_ =~ /reject=550/) {
>
> if($_ =~ /\[(\d+\.\d+\.\d+\.\d+)\]/) {
> $address = $1;
>
> # Add address to firewall filtering here
does the ip part come after or before the reject=550 part? will the
reject=550 part always separeted by the ip part with at lease one byte? try
something like:
if(/reject=550.+(\[(\d+\.\d+\.\d+\.\d+)\])/){
$address = $1;
}
assume reject=550 comes first, separate by at least one byte, follow by the
ip portion. i think you get the idea.
david
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]