my $max while ( my $file = readdir(DIR) ) { $max = $file if $file gt $max; } print $max;