Gossamer Forum
Quote Reply
Number_of_Links
I want to add a comma to the Number of Links displayed by the <%Number_of_Links%> tag.

I would like to do this by adding a global, and using the following routine:

sub {

my $numlinks = ####;

$numlinks = &commify($numlinks);

sub commify {
local $_ = shift;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;

}

return $numlinks;

}

I just need some help in what to put where I have #### in the code -- the actual code to select the number of links for a particular category. I know the rest of my routine works as I use it elsewhere.

Your help is appreciated,

Ryan
Quote Reply
Re: [relledge] Number_of_Links In reply to
You can't use that code. You have one sub-routine nested within another which is not a good thing.

Use:

Code:
sub {
local $_ = shift;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
Quote Reply
Re: [Paul] Number_of_Links In reply to
I beg to differ. I do that any many sub routines and it works fine.

If anyone can please just let me know how to select the number of links in a category, to replace the ###, I would appreciate it. I know perl just fine and don't need help with the stucture of my sub routines, I just don't know much about all the special ways to query the database in LinksSQL code.

Thanks.
Quote Reply
Re: [relledge] Number_of_Links In reply to
Quote:
I beg to differ. I do that any many sub routines and it works fine.

Hmm I didn't say it didn't work, I said it's a bad idea.

Quote:
If anyone can please just let me know how to select the number of links in a category, to replace the ###, I would appreciate it.

I showed you the code to "commify" the number, you just need to pass $Number_of_Links into the global.

<%commify($Number_of_Links)%>