I'm learning perl's *nix system tools and I've been staring at the following two sentences for several minutes:
You can think of getpwuid() and getpwnam() operators as random access -- they grab a specific entry by key so you have to have a key to start with. Another way of accessing the password file is sequential access -- grabbing each entry in some apparently random order.
I'm 99% sure this is a开发者_JAVA技巧 typo, but if it isn't I'm clearly missing a key idea. Can anyone shed some light on the subject?
Thanks in advance.
Not a typo, but very poorly worded. getpwuid
looks up a passwd entry by UID. getpwnam
looks up a password entry by name. These are "random access" like system memory is "random access"; you can pick which one you want by providing a key. (For system memory, the "key" is the address. For getpwuid
, the key is the UID. For getpwnam
, the key is the name.)
These are in contrast to getpwent
, which simply returns the "next" entry from the passwd file. The entries will be returned in some unspecified order. This is "sequential access", like reading a file from disk. Although for getpwent
you do not know what order the results will appear.
The wording is confusing because they use the word "random" for both the phrase "random access" (like a memory) and "apparently random order" (by which they mean "unspecified order").
They should have said "unspecified order" or "indeterminate order" rather than "apparently random order".
精彩评论