Created
January 4, 2016 02:00
-
-
Save claudinec/30fa64846604a830cc7b to your computer and use it in GitHub Desktop.
usd2aud.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| # Convert from USD to AUD. | |
| # Time-stamp: <2009-03-15 19:55:57 claudine> | |
| use strict; | |
| use warnings; | |
| use Carp; | |
| use Finance::Quote; | |
| use Getopt::Long; | |
| # one argument: USD | |
| my $usd; | |
| GetOptions('usd|u=f' => \$usd) or croak(); | |
| # Quote object | |
| my $q = Finance::Quote->new; | |
| # update rate first | |
| my $rate = $q->currency("USD","AUD") or croak(); | |
| print "USD/AUD rate is $rate\n"; | |
| # convert to AUD | |
| my $aud = $usd * $rate; | |
| print "US $usd = AU $aud\n"; | |
| 1; | |
| __END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment