Why do you want it as a global? They are less efficient. It's much better (and cleaner) to have them in a .pm file
You could get away with doing it in a global as:
do_markup_table
$_[0] =~ s{\[t\](.*)\[\/t\]}{do_table($1)}segm;
return $_[0];
sub do_table {
my @vals;
foreach (split /\n/, $_[0]) {
chomp;
next if length $_ < 1;
my ($day,$times) = split /:/, $_;
push @vals, qq|
<tr>
<td>$day</td>
<td>$times</td>
</tr>\n|
}
return qq|<table>| . join("",@vals) . qq|</table>|;
}
}
Then call with <%do_markup_table($Description)%>
But it may not work as expected, and its all much harder to debug in the future if anything goes wrong.
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
You could get away with doing it in a global as:
do_markup_table
Code:
sub { $_[0] =~ s{\[t\](.*)\[\/t\]}{do_table($1)}segm;
return $_[0];
sub do_table {
my @vals;
foreach (split /\n/, $_[0]) {
chomp;
next if length $_ < 1;
my ($day,$times) = split /:/, $_;
push @vals, qq|
<tr>
<td>$day</td>
<td>$times</td>
</tr>\n|
}
return qq|<table>| . join("",@vals) . qq|</table>|;
}
}
Then call with <%do_markup_table($Description)%>
But it may not work as expected, and its all much harder to debug in the future if anything goes wrong.
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!