why
my $parallel_running_command = parallelize_bash_commands([@commands]);
and not simplier and more efficient
my $parallel_running_command = parallelize_bash_commands(\@commands);
Here is same but simplier, thus more maintenable version of parallelize_bash_commands function:
sub parallelize_bash_commands {
return join '', map { "( ( $_ ) & );" } @$_;
}
Why you checking for correctness of passed array ref into this sub? Let Perl do it.
Instead, you'll better check whether your passed commands contain "dangerous" characters like "(", "&", etc, which will break your sub in a much worse way!