gcthompson has asked for the wisdom of the Perl Monks concerning the following question:
If the contents of $$ref_sRecord contains :sub getSubjects($) { my $ref_sRecord = $_[0]; my @aSubNos = $$ref_sRecord =~ m/<subno>(.+?)<\/subno>/sig; .... }
This array aSubNos should contain 2.1.c and 2.2 (in this case). This works fine for the majority of data but on occasion it fails and doesn't match anything. For some reason, replacing.... <level>1</level> <subject> <subno>2.1.c</subno> <subtxt>Subject 1</subtxt> <subno>2.2</subno> <subtxt>Subject 2</subtxt> </subject> ....
withmy @aSubNos = $$ref_sRecord =~ m/<subno>(.+?)<\/subno>/sig;
makes it work consistently across all of my data. The perl script is running on Perl v5.8.4 (sun4-solaris). The question is, why? This doesn't make any sense to me.my $sString = $$ref_sRecord; my @aSubNos = $sString =~ m/<subno>(.+?)<\/subno>/sig;
janitored by ybiC: formatting tweaks for legibility
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Weirdness with matching into an array
by ambrus (Abbot) on Jan 26, 2005 at 15:02 UTC | |
|
Re: Weirdness with matching into an array
by dave_the_m (Monsignor) on Jan 26, 2005 at 11:01 UTC | |
by gcthompson (Initiate) on Jan 26, 2005 at 12:03 UTC |