Created
August 6, 2014 17:36
-
-
Save ype/f94706c2497f1575d254 to your computer and use it in GitHub Desktop.
Quick Currency Quotes with Perl (for use with Ledger-CLI)
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 | |
| $timeout = 60; | |
| use Finance::Quote; | |
| use POSIX qw(strftime localtime time); | |
| die "Usage: $0 FROM TO\n" unless defined($ARGV[1]); | |
| my $q = Finance::Quote->new; | |
| my $exchange_rate = $q->currency($ARGV[0],$ARGV[1]); | |
| $q->timeout($timeout); | |
| if ($exchange_rate, "price") { | |
| print "P", " "; | |
| print strftime('%Y/%m/%d %H:%M:%S', localtime(time())); | |
| print " ", $ARGV[0], " ", $exchange_rate, " ", "\n"; | |
| } else { | |
| exit 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment