Randal L. Schwartz wrote:
"Rajnikant" == Rajnikant  <[EMAIL PROTECTED]> writes:

Rajnikant> Is there any such way to get home directory of user?
Is there any such way that this might be, perhaps, oh, a FAQ?

Oh, yes, let's see.

    $ perldoc -q tilde
    Found in /usr/libdata/perl5/pod/perlfaq5.pod
      How can I translate tildes (~) in a filename?

        Use the <> (glob()) operator, documented in perlfunc. Older versions of
        Perl require that you have a shell installed that groks tildes. Recent
        perl versions have this feature built in. The File::KGlob module
        (available from CPAN) gives more portable glob functionality.

        Within Perl, you may use this directly:

                $filename =~ s{
                  ^ ~             # find a leading tilde
                  (               # save this in $1
                      [^/]        # a non-slash character
                            *     # repeated 0 or more times (0 means me)
                  )
                }{
                  $1
                      ? (getpwnam($1))[7]
                      : ( $ENV{HOME} || $ENV{LOGDIR} )
                }ex;

OK, so you may have not known "tilde".  But you should be reading
the FAQ titles at least weekly until you are bored to tears from them,
and probably reading the entire FAQ at least bi-monthly.

thanks guys!!

But I guess there is no way to get user id.. ? I will read FAQ more... (till I am bored to tears ? :-) )

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to