#!/usr/bin/perl

# Usage: ./pronostic.pl < template > result

use Digest::MD5 "md5_hex";

my $who = "jeremie";

# This is where the magic happens!
sub score {                       # Argument: match, as "TeamA-TeamB"
  $_ = substr md5_hex(shift), -3; # Take last 3 hex digits of MD5 digest
  y/90a15//cd; return length;     # Count goals of TeamA against TeamB \o/
}

while (<>) {
  chomp; print;
  print $who if /^Pronostics/;
  if (/-/) {
    s/\W*$//; my ($a, $b) = split /-/;
    print score("$a-$b") . "-" . score("$b-$a");
  }
  print "\n";
}

