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
In reply to Weirdness with matching into an array by gcthompson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |