in reply to How can I create an array of filenames?

sub get_files { @files = reverse (map { (split (/\s+/))[8]; } `ls -lrt`); foreach $filename (@files[0..3]) { print "$filename\n"; } }
This baby puts the last four files modified most recently in the current directory into the array @files. If you want to select a directory, whack in a chdir() before you call the subroutine. I then print the name of each file in the array for your info.

HTH

Azatoth a.k.a Captain Whiplash

Make Your Die Messages Full of Wisdom!
Get YOUR PerlMonks Stagename here!
Want to speak like a Londoner?