Win has asked for the wisdom of the Perl Monks concerning the following question:
$Command = join(' ', 'EXEC', $SPROC, join(', ', @CHOICE[1 .. $elements_in_array])) . ''; [download]
Updated.
I can't help you with that code, there are two joins and so many undefined variables that trying to understand what you intend is hopeless.
However the following snippet may help resolve your problem:
use strict; use warnings; my @array = (1, 2, undef, 4, 5, undef, undef, 8, 9); print join ' ', grep $_, @array; [download]
Prints:
1 2 4 5 8 9 [download]
Just a nit,
will not include false but defined values:
use strict; use warnings; my @array = (1, 2, undef, 4, 5, 0, undef, 8, 9); print join (' ', grep $_, @array)."\n"; print join (' ', grep { defined } @array)."\n"; [download]
1 2 4 5 8 9 1 2 4 5 0 8 9 [download]
Argh, I've not been bitten enough by that in real code. I have been bitten enough here by it that I should know better by now!
Thanks for clarifying that for OP and the gentle reminder for me. :)
$Command = join(" ", grep { defined } ('EXEC',$PROC), join(', ', grep { defined } @CHOICE[1 .. $elements_in_array])) . ''; [download]