Un saludo,.
Tengo este código con el que busco hasta el final de la linealínea pero me gustaría que busquebuscara hasta que se consigueencuentre un punto, para que me extraiga un texto con coherencia.
#!/usr/bin/perl
use strict;
use warnings;
my $body;
my $smtpCode;
$body = "Diagnostic-Code: smtp; 550-5.1.1 The email account that you tried to reach does
not exist. Please try 550-5.1.1 double-checking the recipient's email
address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1
https://support.google.com/mail/?p=NoSuchUser s35si4587705qvc.145 - gsmtp";
foreach ( split( /\n/, $body ) ) {
next if (/^\s*$/);
if ( $_ =~ /^Diagnostic-Code:\ssmtp;\s(.*)$/) {
$smtpCode = $1;
print $smtpCode; #Salida: 550-5.1.1 The email account that you tried to reach does
}
}
#!/usr/bin/perl
use strict;
use warnings;
my $body;
my $smtpCode;
$body = "Diagnostic-Code: smtp; 550-5.1.1 The email account that you tried to reach does
not exist. Please try 550-5.1.1 double-checking the recipient's email
address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1
https://support.google.com/mail/?p=NoSuchUser s35si4587705qvc.145 - gsmtp";
foreach ( split( /\n/, $body ) ) {
next if (/^\s*$/);
if ( $_ =~ /^Diagnostic-Code:\ssmtp;\s(.*)$/) {
$smtpCode = $1;
print $smtpCode; #Salida: 550-5.1.1 The email account that you tried to reach does
}
}
O que por lo menos muestre todo el parrafo despuespárrafo después de Diagnostic-Code: smtp;