Hello Tom, > On 5/18/07, Martin Barth <[EMAIL PROTECTED]> wrote: > > > print "********** " . eval("getpwnam('christian')") ."\n"; sleep 10; > > Why are you (mis-)using the evil eval? > > > if I do a perl -wle 'print getpwnam("christian")' the correct (new) uid is > > returned. > > So, if you don't use the evil eval, everything works fine?
I forgot to remove this eval. I just added this becaus on commandline a new fresh perl -wle 'getpwnam("...") ' works fine. > That should be the end of the story. ("Doctor, it hurts when I stick > my finger in my eye." "Stop doing that.") But in case you're burning > with curiosity about what's going on with eval, here you go: > > I suspect that your perl has cached the result of compiling that > string, which is to say it's cached the old uid. If you need an eval > string to be repeatedly re-compiled at runtime (and you fail to notice > that this is a sign that your algorithm needs fixing) simply ensure > that it's a different string each time you eval it. Perhaps something > like this: > > my $serial; > my $evil_result = eval("getpwnam('christian')" . "\n#" . ++$serial); > > But this is no endorsement of the evil eval. You've found merely one > of its evil pitfalls. Avoid, avoid, avoid. > > Cheers! well i just added that eval, because I really wanted perl to interprete string new, like the perl -wle ... on the commandline. I'll try your code on monday at work. I hope that will help. But I am afraid it won't because as you said, without eval it shoud have worked. > > --Tom Phoenix > Stonehenge Perl Training > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/