Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [Robert] Regex for dl/dt/dd or table

Quote Reply
Re: [Robert] Regex for dl/dt/dd or table In reply to
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
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!
Subject Author Views Date
Thread Regex for dl/dt/dd or table Robert 7453 Dec 4, 2017, 8:34 AM
Thread Re: [Robert] Regex for dl/dt/dd or table
Andy 7349 Dec 5, 2017, 12:23 AM
Thread Re: [Andy] Regex for dl/dt/dd or table
Robert 7339 Dec 5, 2017, 3:00 AM
Thread Re: [Robert] Regex for dl/dt/dd or table
Andy 7335 Dec 5, 2017, 4:15 AM
Thread Re: [Andy] Regex for dl/dt/dd or table
Robert 7334 Dec 5, 2017, 6:11 AM
Thread Re: [Robert] Regex for dl/dt/dd or table
Andy 7329 Dec 5, 2017, 7:03 AM
Thread Re: [Andy] Regex for dl/dt/dd or table
Robert 7318 Dec 5, 2017, 2:35 PM
Thread Re: [Robert] Regex for dl/dt/dd or table
Andy 7304 Dec 5, 2017, 11:58 PM
Thread Re: [Andy] Regex for dl/dt/dd or table
Robert 7250 Dec 7, 2017, 4:19 AM
Thread Re: [Robert] Regex for dl/dt/dd or table
Andy 7238 Dec 7, 2017, 10:45 AM
Thread Re: [Andy] Regex for dl/dt/dd or table
Robert 7239 Dec 7, 2017, 11:14 AM
Post Re: [Robert] Regex for dl/dt/dd or table
Robert 7222 Dec 7, 2017, 12:21 PM