tonguim
04-03-2005, 06:03 AM
Hi all,
it is about an assignement
the program that i have to write, allow the change from the canadian currency to a foreign currency; when i click the submit button on the form , i should have the result of the change. For example, if i type $4 i should have the equivalent to euro, and some others foreigns currencies.
To build this application, i've to have 4 files:
-the first one is the html form
-the second is the file that i called "exercice5.pl": this one have to use the files (sub-routines) exercice5_conversion.pl, and exercice5_affiche_html.pl
-the third one is call exercice5_conversion.pl: it contents a sub routine that uses 2 parameters and returns the result of the change.
-the four one is call "exercice5_affiche_html"; it contents a sub routine that uses 3 parameters and displays, into a table, on each line, the country, the change rate, and the amount that we got after the change)
<html>
<head>
</head>
<body
<form action = "" method = POST>
<table border = 1 cellpadding =0 cellspacing =0 align = center height = 150>
<tr>
<td>
<table>
<tr><td colspan = 2><h2>This form change the canadians dollars to foreigns currencies</h2></td>
</tr>
<tr>
<td align = right><b>Please type your name:</b></td>
<td><input type = text name = nomHtml size = 60></td>
</tr>
<tr>
<td align = right><b>Please type an amount to change:</b></td>
<td><input type = text name = amountHtml size = 30></td>
</tr>
<tr> <td colspan = 2 align = center><input type = submit name = btonHtml value = submit></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
exercice5.pl
#!c:/perl/bin/perl.exe
print "Content-type: text.html\n\n";
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
require 'exercice5_conversion.pl'; #sub routine: change
require 'exercice5_affiche_html.pl'; #sub routine: display the results of the change
#hash table containing the currencies, the countries and the rate of change
%conversion = ( 'Dollar-Etats-Unis' => .8135,
'Euro-Europe' => .6226,
'Yen-Japon' => 85.83,
'Rand-Afrique du Sud' => 4.8299,
'Afghani-Afghanistan' => 34.80,
'Rouble-Russie' => 22.76,
'Livre-Egypte' => 4.7320,
'Dinar-Iraq' => 1189.45,
'Couronne-Norvege, => 5.1773);
exercice5_conversion.pl
#!c:/perl/bin/perl.exe
print "Content-type: text.html\n\n";
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use CGI 'param';
$amount_typed = param ('amountHtml');
require 'exercice5_conversion.pl'; #sub routine: change
require 'exercice5_affiche_html.pl'; #sub routine: display the results of the change
@elements = values %conversion;
foreach $taux_conversion (@elements)
{
$resultat = &conversion ($amount_typed, $change_rate);
}
sub conversion
{
$montantAttendu = $montantPerl*$taux_conversion;
}
1;
exercice5_affiche_html.pl
#!c:/perl/bin/perl.exe
print "Content-type: text.html\n\n";
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
require 'exercice5_conversion.pl'; #sub routine: change
require 'exercice5_affiche_html.pl'; #sub routine: display the results of the change
@elements = values %conversion;
sub affiche_html
{
($country, $change_rate, $amount_got) = each %conversion;
}
1;
May you help me? Thank you.
it is about an assignement
the program that i have to write, allow the change from the canadian currency to a foreign currency; when i click the submit button on the form , i should have the result of the change. For example, if i type $4 i should have the equivalent to euro, and some others foreigns currencies.
To build this application, i've to have 4 files:
-the first one is the html form
-the second is the file that i called "exercice5.pl": this one have to use the files (sub-routines) exercice5_conversion.pl, and exercice5_affiche_html.pl
-the third one is call exercice5_conversion.pl: it contents a sub routine that uses 2 parameters and returns the result of the change.
-the four one is call "exercice5_affiche_html"; it contents a sub routine that uses 3 parameters and displays, into a table, on each line, the country, the change rate, and the amount that we got after the change)
<html>
<head>
</head>
<body
<form action = "" method = POST>
<table border = 1 cellpadding =0 cellspacing =0 align = center height = 150>
<tr>
<td>
<table>
<tr><td colspan = 2><h2>This form change the canadians dollars to foreigns currencies</h2></td>
</tr>
<tr>
<td align = right><b>Please type your name:</b></td>
<td><input type = text name = nomHtml size = 60></td>
</tr>
<tr>
<td align = right><b>Please type an amount to change:</b></td>
<td><input type = text name = amountHtml size = 30></td>
</tr>
<tr> <td colspan = 2 align = center><input type = submit name = btonHtml value = submit></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
exercice5.pl
#!c:/perl/bin/perl.exe
print "Content-type: text.html\n\n";
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
require 'exercice5_conversion.pl'; #sub routine: change
require 'exercice5_affiche_html.pl'; #sub routine: display the results of the change
#hash table containing the currencies, the countries and the rate of change
%conversion = ( 'Dollar-Etats-Unis' => .8135,
'Euro-Europe' => .6226,
'Yen-Japon' => 85.83,
'Rand-Afrique du Sud' => 4.8299,
'Afghani-Afghanistan' => 34.80,
'Rouble-Russie' => 22.76,
'Livre-Egypte' => 4.7320,
'Dinar-Iraq' => 1189.45,
'Couronne-Norvege, => 5.1773);
exercice5_conversion.pl
#!c:/perl/bin/perl.exe
print "Content-type: text.html\n\n";
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use CGI 'param';
$amount_typed = param ('amountHtml');
require 'exercice5_conversion.pl'; #sub routine: change
require 'exercice5_affiche_html.pl'; #sub routine: display the results of the change
@elements = values %conversion;
foreach $taux_conversion (@elements)
{
$resultat = &conversion ($amount_typed, $change_rate);
}
sub conversion
{
$montantAttendu = $montantPerl*$taux_conversion;
}
1;
exercice5_affiche_html.pl
#!c:/perl/bin/perl.exe
print "Content-type: text.html\n\n";
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
require 'exercice5_conversion.pl'; #sub routine: change
require 'exercice5_affiche_html.pl'; #sub routine: display the results of the change
@elements = values %conversion;
sub affiche_html
{
($country, $change_rate, $amount_got) = each %conversion;
}
1;
May you help me? Thank you.