[ic] {Spam?} Simple Bitcoin exchange rate calculator.

Rick Bragg lists at gmnet.net
Wed Sep 14 18:45:11 UTC 2011


Here is a simple Bitcoin exchange calculator that gets data from
bitcoinexchangerate.net  It only grabs the USD rate.  It takes "usd" as
an input and calculates the exchange.  If for some reason the
bitcoinexchangerate.net site is down, or has changed, it will return
nothing at all.  Other wise it should return the exchange.  It requires
WWW::Mechanize and Math::Round

sample usage: [bitcoinexchange usd="100.00"]



UserTag bitcoinexchange Order usd
UserTag bitcoinexchange addAttr
UserTag bitcoinexchange Routine <<EOR

use WWW::Mechanize;
use Math::Round;

sub {
my ($usd) = @_;
 my $url = 'http://bitcoinexchangerate.net';
 my $browser = WWW::Mechanize->new();

 if ($browser->success()){
    my $text = $browser->content( format => 'text' );
    my @values = split('USD', $text);
    my $val = @values[0];
    $val =~ s/1 Bitcoin =//;
    $val =~ s/[A-Za-z]//g;
    $val =~ s/ //g;
    if ($val =~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/ ) {
        #Its a number!";
        return nearest (.0001, ($usd / $val));
    } else {
  }else{ # End of Page success  

More information about the interchange-users mailing list