Reputation: 1872
When using quote word in perl is it possible to have a undef value in the list?
my @ number_array = qw( 1 2 3 4 5 6 7 8 9 10 )
What I am wondering is would it be possible to add a undef value to that list so that it contained 11 values instead of 10?
Upvotes: 2
Views: 323
Reputation: 385897
qw(...)
is equivalent to
(split(' ', q(...), 0))
As for the answer to your question, it depends on what you mean by "null".
split
returns strings.split
cannot return those with those operands.You would have to build your list by another means. For example,
my @array = (qw( 1 2 3 4 5 6 7 8 9 10 ), undef);
Or even the similar
my @array = (1..10, undef);
Upvotes: 5
Reputation: 22421
There's no null
in perl, but you can use undef
. Since qw
explicitly operates only with space-separated string, you'd have to specify it outside of qw
, but you can easily write several lists inside brackets:
my @number_array = (undef, qw( 1 2 3 4 5 6 7 8 9 10 ));
print scalar @number_array;
>11
Upvotes: 5