Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
A tip from Visualizing recursion with the fib() example is to use Devel::TraceCalls
#!/usr/bin/perl -- use strict; use warnings; use Devel::TraceCalls { Subs => [qw/ hanoi /]}; hanoi( 3, 'A', 'C', 'B', 0 ); sub hanoi { my ($n, $start, $end, $extra) = @_; if ($n == 1) { print "Move disk #1 from $start to $end.\n"; } else { hanoi($n-1, $start, $extra, $end); print "Move disk #$n from $start to $end.\n"; hanoi($n-1, $extra, $end, $start); } } __END__
TRACE: main::hanoi( 3, 'A', 'C', 'B', 0 ) TRACE: +-main::hanoi( 2, 'A', 'B', 'C' ) TRACE: | +-main::hanoi( 1, 'A', 'C', 'B' ) Move disk #1 from A to C. Move disk #2 from A to B. TRACE: | +-main::hanoi( 1, 'C', 'B', 'A' ) Move disk #1 from C to B. Move disk #3 from A to C. TRACE: +-main::hanoi( 2, 'B', 'C', 'A' ) TRACE: | +-main::hanoi( 1, 'B', 'A', 'C' ) Move disk #1 from B to A. Move disk #2 from B to C. TRACE: | +-main::hanoi( 1, 'A', 'C', 'B' ) Move disk #1 from A to C.

In reply to Re: Recursion Confusion by Anonymous Monk
in thread Recursion Confusion by live4tech

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [davido]: Lol, in composing test code for Re: Stupid, yet simple, sort question I managed to fill up /tmp for a moment, causing bash to complain about "pmbash: cannot create temp file for here-document: No space left on device"
    [davido]: hm, sorry, wrong link: Re^3: Perl Program to efficiently process 500000 small files in a Directory (AIX) should be it.

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (2)
    As of 2018-03-18 06:59 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (228 votes). Check out past polls.