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

converting to all-lowercase

Quote Reply
converting to all-lowercase
Hi,
Could someone help me out with what should be an easy global? I wish to take the content of a field "name" and process it to have it entirely in lower case. 'Andy-Pandy' would thus become 'andy-pandy'.
Must be so something like:

sub {
my $tags = shift;
my $lowercase = shift;
$lowercase = $tags->{name};
$lowercase =~ tr/A-Z/a-z/;
return $lowercase;
}

but I know it's wrong.
A little help and explanation would be welcome
Thanks

Last edited by:

charly2: Mar 12, 2005, 8:10 AM
Quote Reply
Re: [charly2] converting to all-lowercase In reply to
You won't need global for this, if you use LSQL v2.99 beta release.

Then you can just use:
<%lc name%>
should do this trick.

Otherwise, for earlier releases, yes, you need that fixed global:
Code:
sub {
my $tags = shift;
my $lowercase = $tags->{name};
$lowercase =~ tr/A-Z/a-z/;
return $lowercase;
}

A shorter, optimized one is here:
Code:
sub {
return lc($_[0]->{name});
}

The globals are NOT tested at all, but should work.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] converting to all-lowercase In reply to
Thanks a lot. Works fine. Much appreciated.