$ perlbrew install --as perl-5.16.0t -Dusethreads perl-5.16.0
####
$ perlbrew list
* perl-5.16.0 #this perl was already installed
perl-5.16.0t #this is the new install
$perlbrew use perl-5.16.0t
$perlbrew list
perl-5.16.0
* perl-5.16.0t
####
use strict;
use warnings;
use 5.012;
use threads;
use threads::shared;
my $counter :shared;
$counter = 1;
my $name = 'Joe';
sub do_stuff {
my $thread_id = shift;
sleep rand 10;
say "thread number $thread_id";
say "count: $counter";
$counter++;
say $name;
$name = "Cathy";
}
my @threads;
for my $thread_number (1..10) {
push @threads, threads->create('do_stuff', $thread_number);
}
for (@threads) {
$_->join;
}
--output:--
thread number 5
count: 1
Joe
thread number 9
count: 2
Joe
thread number 3
count: 3
Joe
thread number 7
count: 4
Joe
thread number 10
count: 5
Joe
thread number 4
count: 6
Joe
thread number 6
count: 7
Joe
thread number 8
count: 8
Joe
thread number 1
count: 9
Joe
thread number 2
count: 10
Joe
####
$ perlbrew switch perl-5.16.0t
####
Generic command options:
-q --quiet Be quiet on informative output message.
-v --verbose Tell me more about it.