下面是我用分隔符分隔并通过电子邮件列表进一步发送的文件:Device1|City|Street|roadname|region|state|area|country|countrycode
________________________________________________
Device1|City|Street|roadname|region|state|area|country|countrycode
Device2|City|Street|roadname|region|state|area|country|countrycode
Device3|No data found
Device4|No data found
_________________________________________________
my $filename = '/tmp/list.txt';
open my $ifh, '<', $filename
or die "Cannot open '$file' for reading: $!";
local $/ = '';
my $filename = <$ifh>;
my @arr = split(/\|/, $filename , -1);
$Device = $arr[0];
$Region = $arr[2];
$State = $arr[3];
$area = $arr[10];
$country = $arr[19];
$logger->debug("$logid >> file information Device Name: $Device");
$logger->debug("$logid >> file information Region: $Region");
$logger->debug("$logid >> file information State: $State");
$logger->debug("$logid >> file information Area: $area");
$logger->debug("$logid >> file information Country: $country");
close( $ifh );
我能够获得以下信息,但我的要求是每当在显示“未找到数据”的行中将其分配给变量,例如..“模式”,我将通过电子邮件进一步发送。
$smtp->datasend("$Device1|$region|$state|$area|$country\n");
$smtp->datasend("$pattern\n");
谢谢