white-fox has asked for the wisdom of the Perl Monks concerning the following question:

hello monks
i have two question: how can i find wich user use my program....(root or ordinary user)?
and how can i find home user directory?
and another how to get find PID of any program in my code?

Replies are listed 'Best First'.
Re: how to get which user is on
by RazorbladeBidet (Friar) on Mar 28, 2005 at 19:13 UTC
    See also getpwuid, getlogin, and fork
    --------------
    "But what of all those sweet words you spoke in private?"
    "Oh that's just what we call pillow talk, baby, that's all."
Re: how to get which user is on
by ambs (Pilgrim) on Mar 28, 2005 at 19:09 UTC
    Some answers to some of your questions:
    • $> is your real user id
    • $ENV{HOME} is your home, if you are in a *nix like system

    Alberto Simões

      $ENV{HOME} is likely to be the home directory of the current user, but don't count on it. Things such as su, sudo, and cron can commonly either leave it pointing at the wrong place or completely unset). Use the value from getpwuid to be certain.</pedant>

Re: how to get which user is on
by cog (Parson) on Mar 28, 2005 at 19:16 UTC
    Exactly what do you mean by "PID of any program"?

    The PID of the current process if given by special var $$ ... but I'm not sure that's what you want...