The choice of loop constructs is up to you. I strongly recommend that you use File::Basename, however. It is a core module (i.e., it comes with Perl), and it does the job correctly, every time. It is also much easier for the average programmer to read and comprehend: