If the "do something" is simple, could just use a one-liner like:
perl -ne " do_stuff() ; print $. . ' '" exportB.xml
Otherwise, your loop seems fine (you could still use $. instead, which shows the current input record number, of $ctr if you wanted -- see perlvar man page for details).
As long as $ctr or whatever you
print doesn't have a newline in it, it should "roll" the way you want. In my example above i separated each print with a space.
side note -- what's the nature of "do something here"? read: is this something more suited for
XML::Simple or the like?