in reply to Creating a Dynamic Table
I think it's probably easier to just use grep to filter the list while copying it... Something like:
my @tableData = grep ref($_) eq "ARRAY" && # make sure we have an arrayref $_->[0] =~ /\S/ && # first cell non-empty $_->[1] =~ /\S/, # second cell non-empty ( ["Hardware A", "Total Cost A"], ["Hardware B", "Total Cost B"], ["Hardware C", ""], ["", "Total Cost D"], [" ", "Total Cost E"], ["Hardware F", " "], [" ", ""], ["Hardware H", "Total Cost H"], ); # to print out use Data::Dumper; print Dumper \@tableData;
(The literal strings I put in above can of course also be variables...)
Or, if you wanted to use $some_data, as you declared it, it would look like
my @tableData = grep ref($_) eq "ARRAY" && # make sure we have an arrayref $_->[0] =~ /\S/ && # first cell non-empty $_->[1] =~ /\S/, # second cell non-empty @$some_data;
|
|---|