use strict; use warnings; use threads; sub PINGIT { print "PINGIT\n"; return 0; } sub THPING { print "THPING\n"; my @th; for (1..5) { push @th, threads->create(\&PINGIT); } $_->join for @th; return 0; } { my %opts; my @th; for (1..2) { if ($ARGV[0]) { # Doesn't generate error message push @th, threads->create(\&THPING); } else { # Generate error message push @th, threads->create(\&THPING, \%opts); } } $_->join for @th; }