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

Hi Monks,

It must be a post-Christmas, just got back to work problem. All I need is a simple way to get the UID of a file in Perl. I thought this might be covered by filetests, but I can't see that it is and I had a little trawl through the cookbook to no avail. I can't believe a system call to ls is the way forward. What handy Perl command is my repertoire missing?

Bukowski - aka Dan (dcs@black.hole-in-the.net)
"Coffee for the mind, Pizza for the body, Sushi for the soul" -Userfriendly

Replies are listed 'Best First'.
Re: Getting the UID of a file
by Hofmator (Curate) on Jan 08, 2004 at 15:34 UTC
Re: Getting the UID of a file
by borisz (Canon) on Jan 08, 2004 at 15:36 UTC
Re: Getting the UID of a file
by b10m (Vicar) on Jan 08, 2004 at 15:36 UTC
Re: Getting the UID of a file
by ysth (Canon) on Jan 08, 2004 at 16:05 UTC
    Or (for the OO inclined), there is:
    use File::stat; # yes, that's a lower-case s print stat($file)->uid;

      but beware of the BUGS:

      As of Perl 5.8.0 after using this module you cannot use the implicit $_ or the special filehandle "_" with stat() or lstat(), trying to do so leads into strange errors. The workaround is for $_ to be explicit my $stat_obj = stat $_; and for "_" to explicitly populate the object using the unexported and undocumented populate() function with CORE::stat(): my $stat_obj = File::stat::populate(CORE::stat(_));

      -- Hofmator