Localized recursion level in recursive function

Change-Id: If0ff8f88c9b5669b0874f5f34f3d883a213bef8c
diff --git a/script/tei2korapxml b/script/tei2korapxml
index 590daad..81f0f30 100755
--- a/script/tei2korapxml
+++ b/script/tei2korapxml
@@ -161,7 +161,6 @@
 my ( $_IDX,                                          # value is set dependent on $_XCT_LN - for extracting array of child elements from element in $tree_data
      $e,                                             # element from $tree_data
      $n,                                             # tag name of actual processed element $e
-     $rl,                                            # recursion level
      $dl,                                            # actual length of string $data
      @oti,                                           # oti='open tags indizes' - a stack of indizes into @structures, where the top index in @oti
                                                      #                            represents the actual processed element from @structures
@@ -297,7 +296,7 @@
           $tokens->reset;
         }
 
-        $dl = $rl = 0;
+        $dl = 0;
 
         # ~ whitespace related issue ~
         $add_one = 0;
@@ -305,10 +304,7 @@
 
 
         # ~ recursion ~
-
-        retr_info( \$tree_data->[2] ); # parse input data
-
-        $rl--;
+        retr_info(1, \$tree_data->[2] ); # parse input data
 
 
         # ~ write data.xml ~
@@ -499,6 +495,9 @@
 
 
 sub retr_info { # called from main()
+  # recursion level
+  # (1 = topmost level inside retr_info() = should always be level of tag $_TEXT_BODY)
+  my $rl = shift;
 
   #  Notes on how 'XML::CompactTree::XS' works
   #
@@ -592,9 +591,6 @@
   #  ${${\$data->[2]}}[0]->[0] (= $data->[2]->[0]->[0]).
 
 
-  $rl++; # recursion level (1 = topmost level inside retr_info() = should always be level of tag $_TEXT_BODY)
-
-
   foreach $e ( @{${$_[0]}} ){ # iteration through all array elements ($_[0] is a reference to an array reference)
 
 
@@ -679,9 +675,7 @@
 
       if ( defined $e->[$_IDX] ){  # do no recursion, if $e->[$_IDX] is not defined (because we have no array of child-nodes, e.g.: <back/>)
 
-        retr_info( \$e->[$_IDX] ); # recursion with array of child-nodes
-
-        $rl--; # return from recursion
+        retr_info($rl+1, \$e->[$_IDX]); # recursion with array of child-nodes
       }