root/misc/currency

Revision 1953 (checked in by miyagawa, 14 years ago)

uppercase to as well

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Getopt::Long;
5 use Finance::Currency::Convert::Yahoo;
6
7 my $to   = "JPY";
8 GetOptions('--to=s', \$to);
9
10 no warnings 'uninitialized';
11 my $stuff = join ' ', @ARGV;
12 my($quant, $currency) = split /\s+/, $stuff;
13 if ($quant =~ /^\w{3}$/ && $currency =~ /^[\d\,\.]+$/) {
14     ($quant, $currency) = ($currency, $quant);
15 }
16
17 if ($currency !~ /^\w{3}$/) {
18     die "Unknown currency: $currency\n";
19 }
20
21 $currency = uc($currency);
22 $to       = uc($to);
23
24 my $how = Finance::Currency::Convert::Yahoo::convert($quant, $currency, $to) or exit;
25 print "$quant $currency = $how $to\n";
Note: See TracBrowser for help on using the browser.