#!/usr/bin/perl -w my $line = "May 25 10:44:06 postfix/smtpd[6992]: NOQUEUE: reject: RCPT from 13-34-221-131.virtuals.cl[131.221.34.13]: 454 4.7.1 : Relay access denied; from= to= proto=ESMTP helo=<192.168.0.133>"; if ($line =~ /Relay access denied/) { $line =~ s/.*\]: //; #print $line; $line =~ s/.*\[//; $line =~ s/\].*//; chomp($line); print $line; }