Gossamer Forum
Home : Products : DBMan : Customization :

Help on creating ref. script

Quote Reply
Help on creating ref. script
I am new to the programing perl.
Please help me on creating a reference table.

I created a Country list (Albania, Angola...) in a drop down menu, but, I want to show people the ISO code.
i.e. Albania's ISO code is AL
I have created another file called "iso.txt" which contains:
Algeria Z
Antigua and Barbuda:AG

and I put the following code on my html.pl:

sub get_iso {
my ($match, $code, $name);

$match = $rec{'Country'};
if ($rec{'Country'} ne "") {
$match = $1;

open (ISO, "iso.txt") or (print "SYSTEM ERR: CANT OPEN FILE" and exit);
while (<ISO> ) {
($code, $name) = split (/:/);
($code eq $match) and close ISO and return $name;
close ISO;
return undef;

then, I'd like to show the ISO code on:

sub html_record {
my (%rec) = @_;
my $iso = &get_iso;

print qq|$iso|;

but the "$iso" doesn't show anything when I viewed on the web.

I hope you understand my explanation.
Or may be there is any other easier method to show the ISO code.

Any help will be appreciated.

Quote Reply
Re: Help on creating ref. script In reply to
I am unsure what you want exactly.

What part of your country listings do you want input into the db and which part do you want displyed in the drop down list.
Quote Reply
Re: Help on creating ref. script In reply to
Hello DarinB, nice to see you again,

well, in my drop down menu, i'd like to show only country names like:
Angola, etc
and these are all (the country names) stored in the .db file

So, when people choose country name Albania for instance, it represents "AL" as well which refer to file iso.txt (Albania:AL)

I hope you understand my problem Smile

Well, thanks DarinB for your help.

Quote Reply
Re: Help on creating ref. script In reply to
Use the Fancy Select Mod, which is located somewhere in this forum. It will do exactly what you want.


Eliot Lee
Anthro TECH,L.L.C

Quote Reply
Re: Help on creating ref. script In reply to
I'm sorry, I am still unclear as to what you want to do with the ISO code.

If you are displaying the full name in the drop down list as well as the full name being stored in the db, where are the ISO codes being used.

Just trying to better understand where you want to go.
Quote Reply
Re: Help on creating ref. script In reply to
DarinB, Eliot, thanks for the reply,

the ISO code is used only for emailing the data to the system that needs 2 digit ISO code in the subject. There is a trading board system in South Africa that can send out to hundreds of mailing list as long as we follow their format. Their format requires the ISO code.

So, my plan with ISO code is:
whenever people post their offers to buy or offers to sell on my board, the dbman will email this data (offers to buy/offers to sell) to the South African site. Instead of sending the whole country name, the dbman must use the ISO code.

Note that, the ISO code will not be stored in .db file, nor displayed in the drop down menu.

The code above was inspired by Alex's script which will display country name by refering to domain name. "Threads Home Page greeting"

Thank you. Smile
Quote Reply
Re: Help on creating ref. script In reply to
Hi Santana,

O.K. Thank you for clearing that up quite a bit.
Judging by your last post you are using the email mod or something similar.

What you can do is use the standard drop down lists created by DBMan to populate the db and to display to users, but in the cfg file make a hash named ...uh %iso.

Like this:
%iso = (
Andorra => 'AD',
Angola => 'AO',
Antigua and Barbuda => 'AG',
Argentina => 'AR',
Then in the sub where you create your email to be sent, loop through this hash looking for a hash key matching the country listed in the record. Substitute the full country name with the iso value associated with that hash key.

This could also be used for simple displaying of iso code on db pages.

Hope this is clear.

[This message has been edited by DarinB (edited December 04, 1999).]
Quote Reply
Re: Help on creating ref. script In reply to
Dear DarinB,

Thanks for the quick reply Smile
I think your idea is much better than mine. So, I did change my .cfg file as you suggested.
But, I am not familiar with programming perl very much.
So, could you advise me on how to loop through the hash like you mentioned?

Let say, I am going to show the ISO code on the:

sub html_record {
my (%rec) = @_;
$rec{$db_key} =~ s/<?.B>//g;


Thank you so much. I really appreciate your help.