My exact problem is about introducing each tag in perl code ... introducing each tag in my perl code is not possible.
Sorry, I don't understand what you mean here. Please see Short, Self-Contained, Correct Example and I know what I mean. Why don't you?. As I said, you can adapt the code I've posted (which I just updated) however you need, but you also haven't shown your expected output.
Update: Ah, I see choroba may have interpreted your issue better than I have. Yes, my $data is meant to be the same thing as the $perl variable from your previous node.