texuser74 has asked for the wisdom of the Perl Monks concerning the following question:
I need an output like:<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.e. i need to store the values in an array and print until i encounter </end>.New Group: ref1 ref2 ref3 New Group: ref4 ref5 New Group: ref6 ref7 ref8
but my current code produces wrong output, pls review and advice.
Thanks in advanceopen(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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem with array
by GrandFather (Saint) on Aug 20, 2008 at 04:25 UTC | |
by johngg (Canon) on Aug 20, 2008 at 10:16 UTC | |
by texuser74 (Monk) on Aug 20, 2008 at 04:35 UTC | |
|
Re: problem with array
by NetWallah (Canon) on Aug 20, 2008 at 04:37 UTC | |
|
Re: problem with array
by jwkrahn (Abbot) on Aug 20, 2008 at 04:19 UTC | |
|
Re: problem with array
by ChOas (Curate) on Aug 20, 2008 at 06:29 UTC | |
|
Re: problem with array
by repellent (Priest) on Aug 20, 2008 at 04:54 UTC |