Hello.
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:
-----------------------
Albania:AL
Algeria Z
Andorra:AD
Angola:AO
Antigua and Barbuda:AG
Argentina:AR
Armenia:AM
Australia:AU
Austria:AT
Azerbaijan:AZ
Bahamas:BS
Bahrain:BH
Bangladesh:BD
Barbados:BB
...
--------------------
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> ) {
chomp;
($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.
Santana
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:
-----------------------
Albania:AL
Algeria Z
Andorra:AD
Angola:AO
Antigua and Barbuda:AG
Argentina:AR
Armenia:AM
Australia:AU
Austria:AT
Azerbaijan:AZ
Bahamas:BS
Bahrain:BH
Bangladesh:BD
Barbados:BB
...
--------------------
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> ) {
chomp;
($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.
Santana