#!/usr/local/bin/perl -w use strict; use Math::Random qw( random_normal ); use Log::Log4perl qw(:easy); use Getopt::Long; GetOptions( \my %opts, "verbose" ); Log::Log4perl->easy_init( $opts{ verbose } ? $DEBUG : $INFO ); my $nof_candidates = 10; my @data = random_normal( $nof_candidates, 10, 2 ); my $ratio = 37.0; my $cutoff = $nof_candidates * $ratio / 100; my @look = splice @data, 0, $cutoff; my @act = @data; my $best = 0; for my $talent ( @look ) { DEBUG "Testing: $talent"; if( $talent > $best ) { $best = $talent if $talent > $best; DEBUG "New best: $best"; } } for my $talent ( @act ) { DEBUG "Acting on: $talent"; if( $talent > $best ) { DEBUG "Taking: $talent"; print "$talent\n"; exit 0; } } DEBUG "Forced to take $act[ -1 ]"; print "$act[ -1 ]\n";