in reply to Reading from ls-lrt (was: Reading)

You don't need to use the -l (letter ell) option if you just want the filenames. You can use -1 (numeral one) to specify one file per line, but that's the default behavior of ls when output isn't going to a terminal anyway.

Additionally, if you want the most recent files, instead of using -r and getting the last five files, you should use the default sort order and get the first five files. Thus:

my @files = (`ls -1t`)[0..4]; chomp(@files);

However, it might be preferable to do all this in Perl, and avoid spawning a shell and relying on the behavior of ls.

opendir(DIR, '.') or die "Can't opendir '.': $!\n"; my @files = readdir(DIR); closedir(DIR); @files = map $_->[0], sort { $b->[1] <=> $a->[1] } map { /^\./ ? () : [ $_, (lstat $_)[9] ] } @files; @files = @files[0..4];