Global symbol "%rates" requires explicit package name at convert1.plx line 7.
Global symbol "%rates" requires explicit package name at convert1.plx line 27.
Global symbol "%rates" requires explicit package name at convert1.plx line 31.
syntax error at convert1.plx line 36, near "$rates("
Global symbol "%rates" requires explicit package name at convert1.plx line 36.
Execution of convert1.plx aborted due to compilation errors.
#!/usr/bin/perl
# Convert1.plx
use warnings;
use strict;
my ($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
);
print "Enter starting currency:";
$from = <STDIN>;
print "Enter your target currency";
$to = <STDIN>;
print "Enter your amount: ";
$value = <STDIN>;
chomp($from,$to,$value);
if (not exists $rates{$to})
{
die "I don't know anything about $to as a currency\n";
}
if (not exists $rates{$from})
{
die "i don't know anything about $from as a currency\n";
}
$rate = $rates($to) / $rates{$from};
print "$value $from is ",$value*$rate," $to.\n";
I am using variations of book examples that I created. This one actually came directly from the book and is still depicting errors. Could someone please help to explain the error? Is this telling me that I have to declare a package notation similar to in java?
This post has been edited by CapC: 01 November 2011 - 11:19 AM

New Topic/Question
Reply


MultiQuote





|