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:
my $some_data =[
["HP Hardware", "Total Cost"],
[$hardware1, $hardwareValue1],
[$hardware2, $hardwareValue2],
[$hardware3, $hardwareValue3],
[$hardware4, $hardwareValue4],
[$hardware5, $hardwareValue5],
[$hardware6, $hardwareValue6],
[$hardware7, $hardwareValue7],
[$hardware8, $hardwareValue8],
[$hardware9, $hardwareValue9],
[$hardware10, $hardwareValue10],
[$hardware11, $hardwareValue11],
[$hardware12, $hardwareValue12],
[$hardware13, $hardwareValue13],
[$hardware14, $hardwareValue14],
[$hardware15, $hardwareValue15],
];
for (my $i=0; $i< scalar($some_data); $i++) {
if ($hardware[$i] eq "") {
}
}
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,
I also Tried
my @tableData = $some_data;
for (my $i=0; $i< scalar(@tableData); $i++) {
my @row = $tableData[$i];
for ( my $j=0; $j< scalar(@row) ;$j++) {
my $cell = $row[$j];
if (($cell eq "") || ($cell eq " ")) {
splice(@tableData, @row, @row)
}
}
}
Any help or suggestions would be helpful, thanks
Ben
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.