in reply to opendir, readir into @array in one line?

sub files_in_dir { my ($dir) = (@_); ( -d $dir ) or die "No such directory $d"; opendir DIR, $d or die "Opendir failed; $!"; my @files = grep !/^\.\.?$/, DIR; closedir DIR; return @files; }

Meanwhile, in a nearby piece of code...

my @files = files_in_dir "/my/dir";

Close to what you wanted?

srand 3.14159; print join("", sort{rand 1<0.5}map{$_^"\037"}split m{ }x,"qmptk|z~wOzm??l]pUqx^k?j"),",\n";