At 11:42 Uhr +0100 14.02.2003, Martin Buchmann wrote:
To distinguish between a file and a directory, use the filetest operators -f and/or -d (do a lookup in Shuck for details).Hello,i have a small script which converts files from dos to mac, i.e. changes the newline character and doing some filename changes. It works on all files in @ARGV, i saved it as a droplet and everything is fine. But no i was thinking about that it would be much better is one a drop a folder or various folders and files, or folders containing folders and files, etc. on the droplet and it processes all files and all the files in the folders. I sure that's a easy thing if you know how to distinguish between files and folders, etc. and i'm also sure that someone has already done this. Could someone give me a hint how to start and where to search? Thanks, Martin
If you want to (recursively) traverse a directory tree, you could use opendir and readdir calls, but I would recommend to use the File::Find module, which does this and much more for you automatically. Just write a "wanted()" sub, to do your file processing, and you are (almost) done.
HTH,
Thomas