You're confusing the concepts of "defined" versus "false", which are very different in Perl. The getpwnam document mentions
If the entry doesn't exist you get the undefined value.Thus, you need a test as mirod has outlined above.
The same consideration applies anytime a value that represents falsehood in Perl (0 or the empty string) can be a legitimate return result from a function. One of my favorite Perl books, Effective Perl Programming has an excellent section on the difference.
In reply to Re: UID 0 and getpwnam
by VSarkiss
in thread UID 0 and getpwnam
by c
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |