Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Strip down output of $related?

Quote Reply
Strip down output of $related?
I'm hoping someone might know how I could strip the output of related down to just the name of the Related Category? The output prints out "Shadows_of_Amn/Item_List/Library"

I'm not very good with my regex...would someone be able to give me a idea on how I could strip the full line:
down to:

This is the code that would be affected:
# Calculate the related entries and put in a <LI> list.
$get_related = $LINKDB->prepare ("CUT TO FIT");
$OUT{related} = '';
while (($name) = $get_related->fetchrow_array) {
$OUT{related} .= qq|<a href="$LINKS{build_root_url}/|;
$OUT{related} .= &build_clean_name ($name);
$OUT{related} .= qq|/$LINKS build_index}">|;
$OUT{related} .= qq|$name</a>\n|;
Or maybe I should create a sub strip_to_name_only($value) in DB_Utils so it can be re-used in other functions?

Quote Reply
Re: Strip down output of $related? In reply to
Take a look at how the build_clean routine does it.

Use split , and the array returned, the last name, or the

my @name_array = split (/\//, $name);
my $cat_name = $name_array($#name_array);

That should put the last "leaf" into the variable $cat_name

PUGDOGŪ Enterprises, Inc.
FAQ: http://postcards.com/FAQ

Quote Reply
Re: Strip down output of $related? In reply to
Beautiful...thanks pugdog, this got it going:

my @name_array = split (/\//, $name);
my $cat_name = $name_array[$#{name_array}];