Acme-Drunk

 view release on metacpan or  search on metacpan

lib/Acme/Drunk.pm  view on Meta::CPAN

    $proof / 2;
}

# For N fluid ounces of alcohol, find pure alcohol content.
sub floz_to_etoh {
    my ($ounces, $percent) = @_;
    $ounces * $percent;
}

# For N ml of alcohol, find pure alcohol content.
sub ml_to_etoh {
    floz_to_etoh( $_[0] * ML_IN_FLOZ, $_[1] );
}

# Convert fluid_ounces of EtOH to weight in pounds.
sub etoh_to_lbs {
    my ($ounces) = @_;
    $ounces * ETOH_WEIGHT;
}

# multiply wtac with gravity of blood.
sub consider_gravity {
    my ($alcohol_weight) = @_;
    $alcohol_weight * GRAVITY_OF_BLOOD;
}

# Remove metabolized alcohol over drinking time.
sub remove_metabolized_alcohol {
    my ($alcohol_weight, $hours) = @_;
    $alcohol_weight - ( $hours * WIDMARK_BETA );
}

# Are you drunk?
sub drunk {
    my (%params) = @_;
    $params{gender} = MALE unless defined $params{gender};
    $params{body_weight}    ||= 150;
    $params{hours}          ||= 2;
    $params{alcohol_weight} = consider_gravity( etoh_to_lbs( $params{alcohol_weight} || 3 ) );

    my $concentration = wtac( @params{qw[body_weight alcohol_weight gender]} );
       $concentration = remove_metabolized_alcohol( $concentration, $params{hours} );

    return $concentration;
}

1;

__END__

=head1 NAME

Acme::Drunk - Get Drunk, Acme Style

=head1 SYNOPSIS

    use Acme::Drunk;

    my $bac = drunk(
		    gender         => MALE, # or FEMALE
		    hours          => 2,    # since start of binge
		    body_weight    => 160,  # in lbs
		    alcohol_weight => 3,    # oz of alcohol
                   );

   $bac >= 0.08 ? call_cab() : walk_home();

=head1 DESCRIPTION

Calculating an accurate Blood Alcohol Concentration isn't as easy as it
sounds. Acme::Drunk helps elevate the burden placed on the Average Joe,
or Jane, to know if they've had too much to drink.

You might think to yourself, "but wait a minute, all I need is a fancy
breathalizer test!" You'd be wrong. For the same reasons that The Man
are often wrong on the street, and have to bring you in for a blood
test. Those generic devices don't take into account important issues in
drunkenness, but Acme::Drunk does.

Now all you need to be a law abiding citizen is your laptop, and we all
have those at the pub, right? Right.

=head2 Constants

Acme::Drunk exports two constants, C<MALE> and C<FEMALE>. You're drunk
if you don't know which one to use.

=head2 C<drunk()>

C<drunk()> takes four named parameters, detailed below, and returns the
Blood Alcohol Concentration (BAC) as a number. Note that C<drunk()>
couldn't return a true value for drunkenness because not all
jurisdictions agree on what the proper BAC level is to be drunk.

=over 4

=item gender

Currently Acme::Drunk only works for humans, and only recognizes C<MALE>
and C<FEMALE> human genders. Use the constants exported for you to
identify your gender.

If your gender or species isn't supported, please email the author.

If you don't know your gender or species, you are drunk.

=item hours

This numeric value represents how long you have been drinking. If you
took your first sip three hours ago, it's important to note. Your body
metabolizes alcohol at a steady per-hour pace.

=item body_weight

Your body weight is also important. Not all people are created equal,
and the amount of alcohol one body can saturate is much different than
another body.

=item alcohol_weight

The weight of alcohol you've had in ounces. This can be hard to



( run in 1.372 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )