Created
November 2, 2012 09:02
-
-
Save b10m/3999611 to your computer and use it in GitHub Desktop.
Outputs the amounts of euros I've saved since I quite smoking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use DateTime; | |
use Mojo::UserAgent; | |
my $price = | |
Mojo::UserAgent->new | |
->get( 'http://www.ah.nl/appie/producten?rq=Gauloises+Blondes+Blue' ) | |
->res->dom->find("p.price")->first->all_text; | |
$price =~ s/[^0-9\.]//g; | |
$price /= 10; | |
printf("%.2f", DateTime->from_epoch(epoch => 1348272000) | |
->delta_days(DateTime->now)->in_units('days') * $price); | |
__END__ | |
This script calculates the amount of days I've not smoked and how | |
much that translates to in money, based on 1 Gauloises Blondes Blue | |
a day. | |
Yes, we look at the current price, which isn't entirely fair, for | |
when it changes, the entire duration will use the new price. But oh | |
well... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment