2

I wanted to simply print out these details for a directory, and I wanted to write the script in perl, any insights?

Mat
  • 202,337
  • 40
  • 393
  • 406
salem
  • 31
  • 1

1 Answers1

4

Use stat to get the UID of the file's owner and getpwuid to get the username for the ID, e.g.:

my $owner = getpwuid((stat)[4]);

Note that, if you call getpwuid in list context, it will return a list of values, the first of which is the username.

jwodder
  • 54,758
  • 12
  • 108
  • 124
  • Is there any way , I could do something similar, but access file version? – salem May 17 '11 at 23:23
  • If by "file version" you mean the version of the application used to create/open/modify the file, that information is stored within the file itself, and extracting it depends on the specific type of file. – jwodder May 17 '11 at 23:25
  • I'm using this script only one applications, not on actual files, so I need to get the version of say an executable, how would I do that? – salem May 17 '11 at 23:28
  • It depends entirely on the executable. By convention, running the executable with the `-v`, `-V`, or `--version` switch will produce version information, but not all programs support this, and the format of the output varies between programs. – jwodder May 17 '11 at 23:30
  • 1
    I think salem is talking about the standard Windows metadata embedded into executable files (see properties dialog in Explorer). – daxim May 18 '11 at 11:19