use strict; use warnings; use List::Util qw(maxstr); my $dir = '.'; my $folders = ""; opendir (DIRHANDEL, "$dir")or warn "can't open $dir\n Error: $!"; while (defined ($folders = readdir(DIRHANDEL))) { my $str = maxstr $folders; print $str,"\n"; } closedir (DIRHANDEL);