<p>Just ran almost the exact same code in perl and this works:</p>

<pre><code>#!/usr/bin/perl

use WWW::Mechanize;

my $btcaddress = "1Enn7YW22vBGvCWrsPQN7vDhnQCYhy221V";

my $mech = WWW::Mechanize-&gt;new();
$mech-&gt;get("http://blockexplorer.com/q/getreceivedbyaddress/" . $btcaddress);   # Check transactions on each address as per masterlist
my $getreceived = $mech-&gt;content;

print $getreceived . "\n";

$mech-&gt;get("http://blockexplorer.com/q/addressbalance/".$btcaddress);   # Check balance on of each address as per master list
my $addressbalance = $mech-&gt;content;

print $addressbalance . "\n";
</code></pre>

<p>Note the address is a random one I found on blockchain.info.</p>

CC BY-SA 3.0
2015-11-25T01:35:59.867Z
2015-11-25T01:35:59.867Z
Jimmy Song
<p>I have a script that uses the Blockchain API to check the current balance on all my accounts one by one. When I reach a certain balance I sweep to a master account.</p>

<p>Am I using the correct code here as I am having errors checking the balance on accounts.</p>

<pre><code>my $mech = WWW::Mechanize-&gt;new();
$mech-&gt;get("http://blockexplorer.com/q/getreceivedbyaddress/".$btcaddress);   # Check transactions on each address as per masterlist
my $getreceived = $mech-&gt;content;

$mech-&gt;get("http://blockexplorer.com/q/addressbalance/".$btcaddress);   # Check balance on of each address as per master list
my $addressbalance = $mech-&gt;content;
</code></pre>

<p>I can check transaction volume ok to reconcile with my accounts but I want to know the current final balance too so I can check that box also.</p>

CC BY-SA 3.0
2015-11-24T23:31:10.843Z
Looks fine. What specific error are you having?
Nick ODell
<api><blockchain.info><perl>
Problems checking BTC current balance using blockchain.info's API, am I correct here?
ryan
# Problems checking BTC current balance using blockchain.info's API, am I correct here?

(Asked by: username_0 on 2015-11-24)

I have a script that uses the Blockchain API to check the current balance on all my accounts one by one. When I reach a certain balance I sweep to a master account.

Am I using the correct code here as I am having errors checking the balance on accounts.

```
my $mech = WWW::Mechanize->new();
$mech->get("http://blockexplorer.com/q/getreceivedbyaddress/".$btcaddress);   # Check transactions on each address as per masterlist
my $getreceived = $mech->content;

$mech->get("http://blockexplorer.com/q/addressbalance/".$btcaddress);   # Check balance on of each address as per master list
my $addressbalance = $mech->content;

```

I can check transaction volume ok to reconcile with my accounts but I want to know the current final balance too so I can check that box also.

**Tags:** api, blockchain.info, perl

> **Comments:**
> **username_1**: Looks fine. What specific error are you having?  

---

## 1 answers

### Answer by username_2 on 2015-11-25. Score: 1

Just ran almost the exact same code in perl and this works:

```
#!/usr/bin/perl

use WWW::Mechanize;

my $btcaddress = "1Enn7YW22vBGvCWrsPQN7vDhnQCYhy221V";

my $mech = WWW::Mechanize->new();
$mech->get("http://blockexplorer.com/q/getreceivedbyaddress/" . $btcaddress);   # Check transactions on each address as per masterlist
my $getreceived = $mech->content;

print $getreceived . "\n";

$mech->get("http://blockexplorer.com/q/addressbalance/".$btcaddress);   # Check balance on of each address as per master list
my $addressbalance = $mech->content;

print $addressbalance . "\n";

```

Note the address is a random one I found on blockchain.info.


---

