Ben Eagle wrote:
> I am making a PDF , which using PDF::Table I am making a table inside 
> that PDF.
> 
> 
> What I am trying to do is make the table dynamic, cause I am passing 
> variables and I do not want a blank table row if the variable is empty. 
> This is what I have tried so far:

> I am thinking if the variable is blank I want to delete the row from 
> $some_data, I don’t know the syntax to do it,

Always supply a complete snippet.  This should be what you need, but
not sure exactly:

use strict;
use warnings;

my $hardware1 = '';
my $hardware2 = 'hardware2';
my $hardware3 = 'hardware3';

my $hardwareValue1 = '';
my $hardwareValue2 = 'hardwareValue2';
my $hardwareValue3 = 'hardwareValue3';

my $some_data = [
   ['HP Hardware', 'Total Cost'],
   [$hardware1, $hardwareValue1],
   [$hardware2, $hardwareValue2],
   [$hardware3, $hardwareValue3],
];

for (my $ii = 0; $ii < @$some_data; ) {
        if ($some_data->[$ii][0] eq '') {
                print "$ii empty - deleting\n";
                splice @$some_data, $ii, 1;     # drop row
                next;           # skip inc of $ii since array shortened
        } else {
                print "$ii $some_data->[$ii][0]\n";
        }
        ++$ii;
}

__END__

_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to