print "above\n"; my $E = binary($k); print "below\n"; #### print "x\n"; print "y\n"; print "z\n"; #### # How many steps we want to take my $steps = 3; sub recur { my ($x) = @_; # Create a number of leading spaces equal to our current $x my $ldr = " " x $x; # Note that we're starting print "${ldr}Start with $x\n"; # We only go to $steps to make it a smallish example if($x >= $steps) { print "${ldr}At $steps, returning.\n"; return; } # Recurse with the next number. Say we're doing it, do it, say we're # done. my $y = $x + 1; print "${ldr}-> Subcall with $y\n"; recur($y); print "${ldr}<- Back from $y\n"; # And now we're done with this number, so step back print "${ldr}Done with $x\n"; } # Start off recur(0); #### % ./tst.pl Start with 0 -> Subcall with 1 Start with 1 -> Subcall with 2 Start with 2 -> Subcall with 3 Start with 3 At 3, returning. <- Back from 3 Done with 2 <- Back from 2 Done with 1 <- Back from 1 Done with 0