#!/strawberry/bin/perl -w
use strict;
use warnings;
print "Currency Conversion exchange\n";
our ($value, $from, $to, $rate, %rates);
%rates=
(
pounds=>1,
dollars=>1.6,
marks=>3.0,
"french francs"=>10.0,
yen=>174.8,
"swiss francs"=>2.43,
drachma=>492.3,
euro=>1.5,
sticks=>30,
stones=>15
);
until(exists $rates{$from})
{
print "Enter your starting currency: ";
our $from=<STDIN>;
chomp $from;
}
until(exists $rates{$to})
{
print "Enter your target currency: ";
our $to=<STDIN>;
chomp $to;
}
until($value!=0)
{
print "Enter your amount (or 0 to quit): ";
our $value=<STDIN>;
chomp $value;
}
print "$value $from is ",$value*$rate," $to.\n";
If I take 'our' away from inside the blocks, I get unitialized variables warnings, and if I put 'our' inside the blocks, then they're treated as separate scoped variables and I get divide by zero errors (or something along that line). I could get this to work by removing the strict pragma, but that's walking backwards.
I've searched several tutorials, and done many various searches to get an idea why, but nothing seems to cover this issue. Any help would be appreciated.

New Topic/Question
Reply



MultiQuote



|