Dear Monks,
I have an input file like this:
<ref id="ref1">
<ref id="ref2">
<ref id="ref3">
</end>
<ref id="ref4">
<ref id="ref5">
</end>
<ref id="ref6">
<ref id="ref7">
<ref id="ref8">
</end>
I need an output like:
New Group: ref1 ref2 ref3
New Group: ref4 ref5
New Group: ref6 ref7 ref8
i.e. i need to store the values in an array and print until i encounter </end>.
but my current code produces wrong output, pls review and advice.
open(IN, '<', "test.in") || die "\nCan't open test.in\n $!\n";
while(<IN>) {
if(<end/>){my @avalues;
if(/<ref id="(.*?)">/){
@avalues = (@avalues,$1);
}print "\nNew Group: @avalues"
}
}
close(IN);
Thanks in advance