Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Getting the UID of a file

by Bukowski (Deacon)
on Jan 08, 2004 at 15:28 UTC ( #319824=perlquestion: print w/replies, xml ) Need Help??

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 (
"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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://319824]
Approved by Hofmator
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2022-01-27 00:49 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (70 votes). Check out past polls.