Gossamer Forum
Quote Reply
Global Compile Error
Ok... can someone tell my why this won't compile?

Code:


sub {

my $cat;

my ($cat) = $DB->table('Category')->select(['Full_Name'],{ ID => $category_id})->fetchrow_array;
return $cat;

}




Probably something really basic, I am sureCrazy

I am just trying to return the corresponding Full_Name for the category_id I find in GT::Dump on browser_category.html. I just thought this may be simpler than the solution at:http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=195650.
Quote Reply
Re: [sooke] Global Compile Error In reply to
$category_id is undefined and undeclared.
Quote Reply
Re: [Paul] Global Compile Error In reply to
woo hoo, got it!

Code:


sub {

#return the Full_Name for a category based on the category_id available in browser_category.html

my $cat;
my ($rec) = @_;
my $category_id = $rec->{category_id};

my ($cat) = $DB->table('Category')->select(['Full_Name'],{' ID' => $category_id})->fetchrow_array;
return $cat;

}


I now just need to tweak it so it can show a condensed version of this ie:

Travel and Tourism/.../Ontario/Niagra

(Top level and last two only)

Smile
Quote Reply
Re: [sooke] Global Compile Error In reply to
Code:
sub {
#return the Full_Name for a category based on the category_id available in browser_category.html

my $rec = shift;
my $category_id = $rec->{category_id};
my $cat = $DB->table('Category')->select( ['Full_Name'], { ID => $category_id } )->fetchrow;

$cat =~ s,(.*?)/.+/(.*?/.+)$,$1/.../$2,;

return $cat;
}

Or something along those lines...that regex is probably a bit sucky...it may work though.

Last edited by:

Paul: May 13, 2002, 3:02 PM
Quote Reply
Re: [Paul] Global Compile Error In reply to
What can I say, fast response, right first time... awesome Paul, thanks!



I noticed you changed fetchrow_array to just fetchrow.... dumb question, but is this simply because $cat is not an array?
Quote Reply
Re: [sooke] Global Compile Error In reply to
fetchrow is the same as fetchrow_array ....Im lazy so prefer the former.
Quote Reply
Re: [Paul] Global Compile Error In reply to
cool, thanks Paul.
Quote Reply
Re: [sooke] Global Compile Error In reply to
Glad you was able to find out how to do it. Smile
See you? Now you start to use Perl & SQL, although you did not know Perl at all. Wink

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] Global Compile Error In reply to
Thanks webmaster!

Yes, Perl no longer looks completley alien to me!Cool

All thanks to the help I get on this forumSmile I have have my first plugin underway!!