When you get a cryptic syntax error which you can't understand how you got, run through
Basic debugging checklist, especially perl -MO=
Deparse:
$ perl -MO=Deparse
#!/usr/bin/perl
use strict;
use warnings;
use threads;
my $t1 = async { qx(perl process1); }
my $t2 = async { qx(perl process2); }
my @out1 = $t1->join;
__END__
Global symbol "$t1" requires explicit package name at - line 10.
- had compilation errors.
use threads;
use warnings;
use strict;
my $t1 = async(sub {
`perl process1`;
}
, my $t2 = async(sub {
`perl process2`;
}
, my(@out1) = ${'t1'}->join));
As Deparse clearly shows, absence of semicolons chained the calls to async and join together, making them arguments to each other.