Gossamer Forum
Home : Products : Links 2.0 : Customization :

Newbie question

Quote Reply
Newbie question
How do I convert a variable $zcat string that say is "United States" to "United_States"

I know the following converts the "/" in the string to "space" (or perhaps just strips it?) and puts into a new variable $mycatname...

@mycatname = split(/\//, $zcat);

Is there a similarly short command for changing all spaces in a variable to underscores?

(I did warn it was a newbie question!)

m.

Last edited by:

Moby: May 13, 2004, 3:05 PM
Quote Reply
Re: [Moby] Newbie question In reply to
Are you working in site_html_templates.pl? The underscores will appear unless told NOT to. From sub site_html_print_cat:

if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }

Remove the &build_clean and you will get the underscores you want. Pretty sure...Unimpressed


Leonard
aka PerlFlunkie
Quote Reply
Re: [Moby] Newbie question In reply to
This code should do it;

Code:
$zcat = s| |_|g;

However, this won't make it URL friendly (as you still need to escape other charachters).

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!
Quote Reply
Re: [Andy] Newbie question In reply to
Thanks guys :)