Gossamer Forum
Home : Products : DBMan : Customization :

If them problem

Quote Reply
If them problem
How do I write the following in perl and where do I put it?

If State = NC then Tribe = Sector 10

Thanks
Quote Reply
Re: [TRD2] If them problem In reply to
Try,
Code:
if ($in{'State'} eq 'NC') { $in{'Tribe'} = 'Sector 10'; }

pop it into sub add_record near the beggining.

chmod
Quote Reply
Re: [chmod] If them problem In reply to
With a quick shift about you could remove the brackets....

Code:
$in{'Tribe'} = 'Sector 10' if $in{'State'} eq 'NC';

Last edited by:

Paul: Jun 26, 2002, 3:18 AM
Quote Reply
Re: [Paul] If them problem In reply to
My way is easier and neater if you want to test for multiple conditions using elsif`s.

I reckon thats what he will want to do.

chmod
Quote Reply
Re: [chmod] If them problem In reply to
Code:
my $tribes = { NC => 'Sector 10', LA => 'Sector 12' };

$in{Tribe} = $tribes->{$in{State}} if defined $tribes->{$in{State}};

Thats a way you can do it without loads of elsif's....you'd just add the state/sector into the hashref.

Last edited by:

Paul: Jun 26, 2002, 4:47 AM
Quote Reply
Re: [Paul] If them problem In reply to
Paul,
cheers I learn a lot from people like you.

And your especially good at actually giving a code example rather than just saying "use a hash", its all much appreciated.

chmod
Quote Reply
Re: [Paul] If them problem In reply to
Ok -

I'm new at this so you have forgive this question, but i need to know -

I'm guessing I take this string and put it in the default.cfg file after the Checkbox fields suff

my $tribes = { NC => 'Sector 10', LA => 'Sector 12' };

My big question is where and what file do i put this string -

$in{Tribe} = $tribes->{$in{State}} if defined $tribes->{$in{State}};

I would guess the html.pl file, but where to use it I dont have a clue.

Help!!


Last edited by:

TRD2: Jun 28, 2002, 2:15 PM