in reply to Re^2: Depth First Search
in thread Depth First Search

Or more like this?

#! perl -slw use strict; use threads; sub traverse { my $href = shift; $_->join for map async{ print "Chapter $_ started"; my $v = $href->{ $_ }; ref( $v ) eq 'HASH' and traverse( $v ); sleep 1; print "Chapter $_ finished"; }, keys %$href; } my %document = ( '1' => { '1.1' => 'xxx', '1.2' => { '1.2.1' => 'xxx', '1.2.2' => ' +xxx' } }, '2' => { '2.1' => { '2.1.1' => 'xxx' } } ); traverse( \%document ); __END__ C:\test>1169475 Chapter 1 started Chapter 2 started Chapter 1.1 started Chapter 1.2 started Chapter 2.1 started Chapter 1.2.2 started Chapter 1.2.1 started Chapter 2.1.1 started Chapter 1.1 finished Chapter 1.2.2 finished Chapter 1.2.1 finished Chapter 2.1.1 finished Chapter 1.2 finished Chapter 2.1 finished Chapter 1 finished Chapter 2 finished

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Depth First Search
by gbar (Initiate) on Aug 10, 2016 at 15:58 UTC
    can I tell how much threads to open (max value of threads ? )

      How do you specify the maximum number of threads with P6?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.