in reply to how do I remember the trailing /

try system("ls -p > data"); and if you are interested in the output you don't have to write to data and then open and read it in again. You can use backticks:

my $output = `ls -p`; # or get each line into an array my @files = `ls -p1`;

--Hofmator