in reply to problem with array
There are a stack of things that look odd in your code with the top of the list being if(<end/>){. However, the following solution to your problem as expressed may help:
use strict; use warnings; my $str = <<DATA; <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> DATA open IN, '<', \$str || die "\nCan't open test.in\n $!\n"; local $/ = '</end>'; while (<IN>) { my @avalues = /="([^"]+)"/g; next unless @avalues; print "New Group: @avalues\n"; } close (IN);
Prints:
New Group: ref1 ref2 ref3 New Group: ref4 ref5 New Group: ref6 ref7 ref8
Note the \$str trick is just to avoid requiring a file external to the sample code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: problem with array
by johngg (Canon) on Aug 20, 2008 at 10:16 UTC | |
|
Re^2: problem with array
by texuser74 (Monk) on Aug 20, 2008 at 04:35 UTC |