Help for this page

Select Code to Download


  1. or download this
    use List::Util 'max';
    my @scores = <FH>;
    my $high_score = max(@scores);
    
  2. or download this
    my $high_score;
    while ( <FH> ) {
        chomp;
        $high_score = $_ if ! defined $high_score || $_ > $high_score;
    }
    
  3. or download this
    sub gen_max {
        # Create an initial default value (or undef)
    ...
    
    # Get the return value of the anonymous sub
    my $high_score = $max->();
    
  4. or download this
    sub gen_reduce {
        my $usage = 'Usage: gen_reduce("initial" => $val, "compare" => $co
    +de_ref)';
    ...
        $maxstr->($_);
    }
    my $long_str = $maxstr->();