- 论坛徽章:
- 0
|
文本格式如下, 判断lu_name, 提取lu_name对应的plu_name,请问大神们用perl怎么实现啊?
第一个AAA 判断是No records, 不用提取了。
第二个BBB 对应的plu_name分别是xxx跟yyy,返回两个数组,BBB, xxx和BBB,yyy
lu_name = AAA
------------------------------------------------------------------------
list_options = FIRST_IN_LIST
No records found matching this query.
------------------------------------------------------------------------
lu_name = BBB
------------------------------------------------------------------------
list_options = FIRST_IN_LIST
plu_alias = ""
plu_name = xxx
description = ""
plu_alias = ""
plu_name = yyy
description = ""
------------------------------------------------------------------------
lu_name = TEST
------------------------------------------------------------------------
list_options = FIRST_IN_LIST
No records found matching this query.
目前只写出匹配lu_name的, 提取出值来
//
foreach $line (@contents) {
next if ($line=~m/-----/); # Do not display seperaters
if ($line=~m/lu_name/) {
@data = split(/=/,$line);
$data[1]=~s/^\s+|\s+$//g; # This removes all blank characters
push @lu_name, $data[1];
next;
}
}
|
|