http://www.perlmonks.org?node_id=35298


in reply to How do I extract a file name from a path string

You should consider solving your problem in a different way. By using the opendir and readdir functions to get the entries in a directory, you automatically have the filename separate from the directory name, and you can do it all without spawning an external process.