sidmuchrock has asked for the wisdom of the Perl Monks concerning the following question:
Right now since I know the number of items I'm expecting, I add a$_ = '1,,3,4,,,'; # a string of 7 possible values @a = split(','); print scalar(@a) . " items in the array\n"; # Sure wish this was 7 print "The second item is $a[1]\n"; # sure wish this was null foreach (@a) { ++$count; print "Item $count is $_\n"; }
after the split, but that feels dirty.$a[7] = undef; pop(@a);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: But I want null values in my array
by Fletch (Bishop) on Mar 11, 2020 at 19:05 UTC | |
|
Re: But I want null values in my array
by kcott (Archbishop) on Mar 11, 2020 at 19:51 UTC | |
by Anonymous Monk on Mar 11, 2020 at 20:04 UTC | |
|
Re: But I want null values in my array
by Marshall (Canon) on Mar 11, 2020 at 23:59 UTC | |
|
Re: But I want null values in my array
by AnomalousMonk (Archbishop) on Mar 11, 2020 at 20:45 UTC | |
|
Re: But I want null values in my array
by hippo (Archbishop) on Mar 12, 2020 at 10:49 UTC |