Gossamer Forum
Home : General : Perl Programming :

What am I doing wrong?

Quote Reply
What am I doing wrong?
I am having a problem... I built a small subroutine for LINKS:

### CHECK Edition Size DAVE MOD

if ($values[$db_editionsize] > "0") {
$edmod = "Edition of $values[$db_editionsize].";
}
else {
$edmod = "";
}


I have added sucessfully a field called EditionSize to the links DB, and it has a number in it. I want it to output, in the case of an entry of 5000... "Edition of 5000", and I want this variable labeled $edmod (for edition modified). Obviously, if it is NOT an edition, I do not want anything written, so I put in the second line $edmod= "";

The above code is in nphbuild.cgi under "sub build_update_newpop"

Then, in site_html_templetes under globals, I have "edmod => $edmod,"

It does NOT pass the variable to my templete.... what am I doing wrong???

Sorry I am so lame, I do appreciate your help!


[This message has been edited by carfac (edited October 18, 1999).]
Quote Reply
Re: What am I doing wrong? In reply to
well.. it's totally in the wrong place..

put it in site_html_link in site_html_templates.pl

like this

Code:
($rec{'EditionSize'} > 0) ? ($edmod = "Edition of $rec{'EditionSize'}") : (undef $edmod);

and then of course in the list of variables passed to the template...

add

Code:
edmod => $edmod,

if you haven't already.. THEN in the template link.html

Code:
<%edmod%>
Quote Reply
Re: What am I doing wrong? In reply to
widgetz:

Thank you so much! I REALLY appreciate your help... a bit overwelmed with perl and all- thanks for the help!
Dave
Quote Reply
Re: What am I doing wrong? In reply to
widgetz:

I copied all the code, and I can't seem to get it to work in my test.

I put the big line right under my %rec = @_;,, and I added the edmod => $edmod, up under globals, but it does not pass the variable...

and the field EditionSize has a value of 5000 in my test...

what am I missing?

Dave
Quote Reply
Re: What am I doing wrong? In reply to
widgetz:

and if it is not too much trouble, could you also tell me how you would code if field XXX is not blank...

Is there a good place on the web to see all these perl commands for variables? I hate being such a bother...

Dave


Quote Reply
Re: What am I doing wrong? In reply to
Hi:

if ($field) {
do_this;
}

A good place on the web is http://www.codebits.com/p5be/

Dan Smile

Quote Reply
Re: What am I doing wrong? In reply to
Dan:

Thanks- that helps. Good link, too. Just so you know.... I bought Perl for Dumbies on the way home.... Wink

Dave