in reply to Iterator Problem with recursion

In noting your problem with re-using the same iterator on $rul over several, simultaneous calls to append(), give each call its own, separate hash and copy %$rul off before iterating over it. You then eliminate the interaction between recursive calls.

my %rul = %$rull; while ( my ( $k, $v ) = each %rul ) { ... }