Skip to content

Instantly share code, notes, and snippets.

@b10m
Created November 2, 2012 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b10m/3999611 to your computer and use it in GitHub Desktop.
Save b10m/3999611 to your computer and use it in GitHub Desktop.
Outputs the amounts of euros I've saved since I quite smoking
#!/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