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 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.
getpwuidlooks up a passwd entry by UID.getpwnamlooks 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. Forgetpwuid, the key is the UID. Forgetpwnam, 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 forgetpwentyou 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”.