eacWash has asked for the wisdom of the Perl Monks concerning the following question:

I'm attempting to check directory permissions in a script and wanted to use "stat" to check the permissions and prepare a report to the user of directories which aren't standard. Stat appears to return an array of 13 strings with the third being $mode. When I tried the following ( testStat being a ubuntu linux directory ), I get what I expect. If I include "use File::stat", I don't. I haven't had a chance to touch perl in a while. Shouldn't I be using File::stat, and shouldn't it work in the following example?:
#!/usr/bin/perl use File::stat; @statTry=stat("testStat"); printf("The value for stat is => %04o\n ", $statTry[2]&0777 ); print("\n");

Replies are listed 'Best First'.
Re: stat and File::stat question for $mode
by Corion (Patriarch) on Nov 20, 2011 at 17:55 UTC

    stat is a built-in function. File::stat overrides it to return an object instead of the list of 13 elements. Decide on which one you want to use, and read the respective documentation. The documentation for stat will not help you if you're using File::stat.

      Thanks, I had one book open to stat with the 13 elements in an array and another describing the module File::stat.
      #!/usr/bin/perl use File::stat; $statTry=stat("testStat"); printf("The value for stat is => %04o\n ", $statTry->mode&0777 ); print("\n");