Finance-Bank-Barclays
view release on metacpan or search on metacpan
Barclays.pm view on Meta::CPAN
@balances=();
foreach $line (@page) {
if($line =~ m/\s*(\d\d-\d\d-\d\d)\s+(\d+)/) {
push @sortcodes, $1;
push @acnumbers, $2;
} elsif($line =~ m/\<b\>\s*(-?&\#163;[0-9,.]+)\s*\</) {
$b=$1; $b =~ s/£//; $b =~ s/,//g;
push @balances, $b;
}
}
croak "sortcodes and balances don't match (".($#sortcodes+1)."/".($#balances+1).")" unless ($#sortcodes == $#balances);
}
my @accounts;
for(my $i=0; $i<=$#sortcodes; $i++) {
push @accounts, (bless {
balance => $balances[$i],
sort_code => $sortcodes[$i],
account_no => $acnumbers[$i],
}, "Finance::Bank::Barclays::Account");
}
return @accounts;
}
package Finance::Bank::Barclays::Account;
# magic
no strict;
sub AUTOLOAD { my $self=shift; $AUTOLOAD =~ s/.*:://; $self->{$AUTOLOAD} }
1;
__END__
# Below is stub documentation for your module. You better edit it!
=head1 NAME
Finance::Bank::Barclays - Check your Barclays bank accounts from Perl
=head1 SYNOPSIS
use Finance::Bank::Barclays;
my @accounts = Finance::Bank::Barclays->check_balance(
memnumber => "xxxxxxxxxxxx",
passcode => "12345",
surname => "Smith",
password => "xxxxxxxx"
);
foreach (@accounts) {
printf "%8s %8s : GBP %8.2f\n",
$_->{sort_code}, $_->{account_no}, $_->{balance};
}
=head1 DESCRIPTION
This module provides a rudimentary interface to the Barclays Online
Banking service at C<https://ibank.barclays.co.uk>. You will need either
C<Crypt::SSLeay> or C<IO::Socket::SSL> installed for HTTPS support to
work. C<WWW::Mechanize> is required.
=head1 CLASS METHODS
check_balance(memnumber => $u, passcode => $p, surname => $s,
password => $w)
Return an array of account objects, one for each of your bank accounts.
=head1 OBJECT METHODS
$ac->sort_code
$ac->account_no
Return the account sort code (in the format XX-YY-ZZ) and the account
number.
$ac->balance
Return the account balance as a signed floating point value.
=head1 WARNING
This warning is from Simon Cozens' C<Finance::Bank::LloydsTSB>, and seems
just as apt here.
This is code for B<online banking>, and that means B<your money>, and
that means B<BE CAREFUL>. You are encouraged, nay, expected, to audit
the source of this module yourself to reassure yourself that I am not
doing anything untoward with your banking data. This software is useful
to me, but is provided under B<NO GUARANTEE>, explicit or implied.
=head1 THANKS
Simon Cozens for C<Finance::Bank::LloydsTSB> and Perl hand-holding.
Chris Ball for C<Finance::Bank::HSBC>.
=head1 AUTHOR
Dave Holland C<dave@biff.org.uk>
=cut
# vi::ts=4:sw=4:ai:cindent
( run in 0.795 second using v1.01-cache-2.11-cpan-0b5f733616e )