in reply to Traverse a directory

File::Find can help you with this, but the benefits of using File::Find over opendir, readdir or glob when you are not recursing downwards through child directories are very limited.

For getting the user information, stat is what you want.

Replies are listed 'Best First'.
Re^2: Traverse a directory
by singho (Novice) on Sep 05, 2012 at 12:40 UTC

    Thanks for your input.

    Well, i was looking for something similar to which gives me output like file command on unix. stat, won't solve my problem.

    my issue is more of finding core files which are owned by root, but also if generated by certain application it should be moved to different areas depending on which program has generated it.

      Ah - if you want to determine the "file type" (which is always guesswork), there is MMagic and File::MimeInfo.

      Update: Looking at File::MMagic, it doesn't seem to have a magic number for recognizing core dump files. A likely faster way would be to determine the magic number(s) for core dump files on your system (maybe from the file magic file, maybe under /etc somewhere) and then write Perl code that reads just enough data to just (reliably) detect those core dump files.