chdir("/bin"); my @file = glob "*"; my @ans = join("\n", @file ); @ans = sort {$l cmp $r} @ans; foreach my $val (@ans){ print $val,"\n"; }