Today I got my password for BT's "View My Bill" service. After spending a while playing around with the fact that you can enter names against phone bills and then view the bill with names instead of numbers, I decided I really liked this feature ...
... except for all the problems.
Particularly the way you can enter multiple numbers against the same person or company, except it won't recognise that fact on your bill, so you have to create a different entry in your address book for every number.
Which would be bad enough, except they also restrict you to 75 entries.
So, I decided it would be fun to download this, dump it to a local database, and then write a simple front-end to let me do it myself. Which would also go back as far as I wanted and not just my last 3 bills.
And they conveniently let you download CSV format, so I don't even need to do all the screen-scraping stuff that I started to do before I thought to check! *doh*
So, I put together a simple module to parse that, and decided it would be fun to have an interface that overloaded the iterator:
my $bill = Data::BT::PhoneBill->new($filename);
while (my $call = $bill->next_call) {
print $call->date, $call->time, $call->destination,
$call->number, $call->duration, $call->cost;
}
}
So I wrote my tests, and tried the code. And everything collapsed. In quite serious fashion:
Operation `!': no method found, argument in overloaded package Data::BT::PhoneBill at /usr/local/lib/perl5/site_perl/5.6.1/Test/Builder.pm line 255.
WHOA! Somehow you got a different number of results than tests ran!
This should never happen! Please contact the author immediately!
END failed--call queue aborted.
After a lot of puzzlement I eventually tracked everything down to a small failing example. It seems Test::Builder doesn't work very well with overloading:
#!/usr/bin/perl -w
use strict;
package Eek;
use overload '<>' => \&get_next;
sub new { bless {} }
sub get_next { 1 }
package main;
use Test::More tests => 1;
ok my $foo = Eek->new, "We got an Eek";
So, playing with all this means I never got to write my database stuff, and I'll probably have to do some "real work" for the rest of the week.
Oh well.