using XyPerl to test content of text register

I am seeing some strange behaviour to do with text registers in a XyPerl program and just wondered if anyone had seen anytthing similar, or had some insight into what might be going on...
I have been trying to set up a very simplified example but unfortunately(!) I cannot get it to do the same thing as seen in my more complex setup.


Essentially I am storing a value into a text register using a XyPerl function
eg.
#--------------------------------------
sub setTR7 {
#--------------------------------------
    my $X = XPPcompo->new();
    my $setNumber = "0";
    $X->px("" , "7");
    $X->set_text("$setNumber");
    $X->pa();
}


Later on I retrieve that value from text register 7, store it in a Perl variable, then do some tests on that variable:
#--------------------------------------
sub readTR7 {
#--------------------------------------
    my $X = XPPcompo->new();
    my $tr7 = $X->get_text(7 , "l");
    if ($tr7 eq "0") {
        print "MATCH";
    } else {
        print "NO-MATCH";
    }
}

In my simplified example that works OK - I have hard-coded a "0" so I get "MATCH" displayed.

However in my more complex setup I need to use
    if ($tr7 eq "0</pa>") {

I can't see why that "</pa>" is necessary?
I believe that when you store into a text register any XML tagging is stored but not output into your main stream when you print it - but can't really see why I am getting a "</pa>" in the result of the get_text call, (but not always).


Any ideas about what is going on would be gratefully received!



thanks,
Paul