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

Can you help me with the providing the uuid instead of the numeric value in the below code?
$filename = "/tmp/gbl7132005"; $uid = (stat $filename) [4]; print "$uid\n";

Replies are listed 'Best First'.
Re: stat & uid
by davidrw (Prior) on Jul 13, 2005 at 20:49 UTC
    Perl has a bunch of the same functions that are in the system library. See the "Fetching user and group info" of perldoc perlfunc, specifically perldoc -f getpwuid
Re: stat & uid
by sh1tn (Priest) on Jul 13, 2005 at 21:15 UTC
    ... $uin = (getpwuid((stat $filename)[4]))[0]; ...


      Thank you!
Re: stat & uid
by socketdave (Curate) on Jul 13, 2005 at 20:51 UTC
    If this is on a *nix system and you have read access to /etc/passwd (probably you're either root, or the system uses a shadow file) you could load it into an array and 'grep /^$uid/, @passwd_file_listing' then '$uuid = split /:/, @array_you_put_grep_output_into'...
      ty
        tc1364, i'd advise you to use the function mentioned by davidrw. my solution will work, but it's ugly, slow and insecure in comparison. sorry about that...