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

I'm working on a format file for Anydata that reads file directories like a database and when using the stat->mode function, it returns a number.

I've looked thru my O'Reilly Perl Bookshelf on CD (my semi-new Perl Programming book *melted* in the car and the pages are falling out (-;) but can not seem to find a table that defines what the numbers mean. Anyone know if one exists and if so where I can get to it?

Thanx

======================
Sean Shrum
http://www.shrum.net

Replies are listed 'Best First'.
Re: stat-mode; numeric definitions
by Kanji (Parson) on Jun 12, 2002 at 21:29 UTC

    Per the stat documentation, "not all fields are supported on all filesystem types", so you really need to consult the documentation for your OS and FS of choice for the appropriate definitions if the perldoc entry isn't meeting your needs.

    Can't help you find such for Windows or the Mac, but for Unix(ish) environments the following may be good places to start...

    If all you're really after is permissions, perhaps you should try the bitmasking technique in the docs or take a look at something like Stat::lsMode (alt.)?

    use Stat::lsMode; $mode = (stat $some_file)[2]; # 33206 $perms = format_mode($mode); # -rw-rw-rw-

        --k.


      AH! Stat:lsMode! That looks perfect!

      Kanji++ : like your really need any more ;-)

      Thanks.

      ======================
      Sean Shrum
      http://www.shrum.net

Re: stat-mode; numeric definitions
by broquaint (Abbot) on Jun 12, 2002 at 21:09 UTC
    Are you referring to the mode field returned by stat()? If so it is the file mode (type and permissions) of the file. You can find more info on what you can do with mode in the stat() docs (you'll want to check out the perldoc stat page as it's info is more up to date).
    HTH

    _________
    broquaint

      Looked the page over but maybe I am reading it wrong.

      The value I am getting back from stat-mode is '33206'. Granted all my files (that I am looking at) are the same type and permission so this number is the same for all of them.

      I didn't see anything on that page that showed how to break this number down (if it *can* be broken down) or what the value itself means.

      ======================
      Sean Shrum
      http://www.shrum.net