I'm trying to craft a global sub that will accept multiple arguments and use them to return an HTML string that's embedded in the page.
Essentially, the global spits out some HTML to build a table around a section of the template, and I want to be able to pass the width and height of the table to the sub. Something like this:
# global begin_table
sub {
my ($width, $height) = shift;
my $output = "";
my $output = "<table width=$width>";
my $output .= "<tr><td height=$height>";
return $output;
}
Assuming it would be called from a template like:
<%begin_table(500,75)%>
But when I've done it like this, I get a value for $width, but $height is always undef.
Looking through the examples, it looks like the initial argument will always be a hashref to tags that are available (e.g., $vars = shift;), but if that's the case, why am I getting a value for $width...particularly one that looks reasonable??
What am I missing here??
Regards,
Eric Longman
Essentially, the global spits out some HTML to build a table around a section of the template, and I want to be able to pass the width and height of the table to the sub. Something like this:
# global begin_table
sub {
my ($width, $height) = shift;
my $output = "";
my $output = "<table width=$width>";
my $output .= "<tr><td height=$height>";
return $output;
}
Assuming it would be called from a template like:
<%begin_table(500,75)%>
But when I've done it like this, I get a value for $width, but $height is always undef.
Looking through the examples, it looks like the initial argument will always be a hashref to tags that are available (e.g., $vars = shift;), but if that's the case, why am I getting a value for $width...particularly one that looks reasonable??
What am I missing here??
Regards,
Eric Longman