in reply to Weirdness with matching into an array
This is just a wild guess, but is it possible that the pos of $$ref_sRecord is not zero when you do the g-matching? That would explain why copying the string helps.