in reply to I want to write a function, you call it ,it will return one matched record each time!
You seem to want to remember where you last left of in FILEIN. To debug your issue, I recommend you print out where each block was found and where it ended.
As a second hint, compare the behaviour of</c>
foreach my $line (<FILEIN>) { ...
and
while (my $line= <FILEIN>) { ...
with respect to $pos.
|
|---|