http://www.perlmonks.org?node_id=190421

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: owner of a file
by tommyw (Hermit) on Aug 15, 2002 at 15:04 UTC

    perldoc -f -X returns...
    -o File is owned by effective uid
    -O File is owned by real uid.

    --
    Tommy
    Too stupid to live.
    Too stubborn to die.

      -O is a file test operator -- it will return either a 1 or "" (or undefined if the file doesn't exist), not the actual UID.

      Update:
      /me is far too hasty. tommyw is right, this does suit the original question.

      -- grummerX

        What? You mean like the original question asked?

        --
        Tommy
        Too stupid to live.
        Too stubborn to die.

Re: owner of a file
by hacker (Priest) on Aug 15, 2002 at 15:05 UTC
    Something like:
    use strict; use File::stat; my $file = $0; my ($st, $uid, $gid); if (($st = stat ($file))) { $uid = $st->uid; $gid = $st->gid; print "Owner = $uid, Group = $gid, File = $file\n"; } else { print "Errors were found on $file\n"; }