Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Why Globals sometimes output code

Quote Reply
Why Globals sometimes output code
Hi,

Why does a Global sometimes just output the code when you include it on a page instead of the result?

Ex:
I inserted <%howhelpful%> into detailed.html and the Global is:

HowHelpful => sub {
my $tags = shift;
my $useful = $tags->{Review_WasHelpful};
my $notuseful = $tags->{Review_WasNotHelpful};
return "0" if (! $useful);
return "100" if (! $notuseful);
my $percent = $useful / ($useful + $notuseful);
my $round = (int($percent * 20 + 0.5) / 20) * 100;
return $round;
}

On the detailed page it just output the above code and not the result. I have experienced this before ?!?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] Why Globals sometimes output code In reply to
I think that a global will output what ever is in it unless it starts with sub { on a line on its own. This enables you to use a global for /header_font etc. as well as perl code. So check that your first line is just

sub {

Laura.
The UK High Street
Quote Reply
Re: [afinlr] Why Globals sometimes output code In reply to
Thanks Laura - getting the grip of Links SQL :-)



Klaus

http://www.ameinfo.com