Skip to content

Instantly share code, notes, and snippets.

@ype
Created August 6, 2014 17:36
Show Gist options
  • Select an option

  • Save ype/f94706c2497f1575d254 to your computer and use it in GitHub Desktop.

Select an option

Save ype/f94706c2497f1575d254 to your computer and use it in GitHub Desktop.
Quick Currency Quotes with Perl (for use with Ledger-CLI)
#!/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