On 5/22/07, Martin Barth <[EMAIL PROTECTED]> wrote:

afer trying a lot of stuff i figured out that following code line works:


my ($login,$pass,$uid,$gid) = (getpwnam($user),rand);

without rand it's still the old user... can anyone explain why perl seems
to cache this? (even without eval)

Well, I'd guess (without looking at the source, which would be
cheating :-) that there's probably a one-user buffer for getpwnam,
which may be shared with getpwuid. If you ask for the same user
repeatedly, you get the cached value.

No; I'm sure that's wrong. Why should your random value affect the
cache? How odd.

While my explanation doesn't seem correct, a correct explanation for
this caching behavior belongs in the documentation. I strongly
encourage you to run the perlbug program, submit your test case
(above), and request that this cache be documented. At a minimum, the
documentation should show how to ensure that a fresh request is made,
by adding rand or another way, in case the underlying system
information has changed.

Thanks!

--Tom Phoenix
Stonehenge Perl Training

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


Reply via email to