这是我的文本文件...我想搜索特定数据并存储它... 我想搜索输出需求历史记录然后打印它搜索所有*输出字段并仅保存其值=234 并打印其数据即 abc , dfg, jh,
输入文件:
*output folk
.....
....
....
*output demand history
*output integ
sd,
lk,
pk,
*output field, value=234;hoxbay edt
abc,
dfg,
jh,
*output field, value=235;hoxbay edt
jh,
lk,
*output fix, value=555;deedfgh
re,
ds,
*fgh ,val=098;ghfd
dsp=pop
mike oop...
**i want this output only........**
输出:
*output field, value=234;hoxbay edt
abc,
dfg,
jh,
*output field, value=235;hoxbay edt
jh,
lk,
*output fix, value=555;deedfgh
re,
ds,
我试过这个......但我不知道如何停下来
output fix, value=555;deedfgh
re,
ds,
代码:
use strict;
use warnings;
use Data::Dumper;
open(IN , "<" , "a.txt");
my $flag=0;
foreach my $line(<IN>)
{
if($line=~/^\*output demand history/i)
{
print $line;
$flag=1;
}
if($line=~/^\*OUTPUT field/i && $flag==1)
{
print $line;
my @array1=split("," ,$line);
my $temp1=shift @array1;
my @array2=split(";",$temp1);
my $elset=shift @array2;
}
if($line=~/^\*OUTPUT FIX/i && $flag==1)
{
print $line;
my @array3=split("," ,$line);
my $temp2=shift @array3;
my @array4=split(";",$temp2);
my $nset=shift @array4;
}
}