in reply to detach for threads

What's happening is what is supposed to happen. When you use 'detach', you're not interested in any return values; hence, the script does its work and exits without "apparently" doing anything. I'd suggest using 'join' instead of detach if you want the counter to return to STDOUT. Here's my attempt at a viable solution:
#!/usr/bin/perl -slw use strict; use Time::HiRes qw(sleep); use threads 'exit' => 'threads_only'; my $thr = threads->create(\&new_func)->join(); $thr = threads->exit(); sub new_func { my $cnt = 0; print "Thread is running..."; while ($cnt <= 500) { print "Count is: $cnt"; sleep 0.002; ++$cnt; } return; }