more useful options | |
PerlMonks |
perlfunc:getprotoentby gods (Initiate) |
on Aug 24, 1999 at 22:42 UTC ( [id://290]=perlfunc: print w/replies, xml ) | Need Help?? |
getprotoentSee the current Perl documentation for getprotoent. Here is our local, out-dated (pre-5.6) version: getprotoent - get next protocols record
getprotoent
These routines perform the same functions as their counterparts in the system library. In list context, the return values from the various get routines are as follows:
($name,$passwd,$uid,$gid, $quota,$comment,$gcos,$dir,$shell,$expire) = getpw* ($name,$passwd,$gid,$members) = getgr* ($name,$aliases,$addrtype,$length,@addrs) = gethost* ($name,$aliases,$addrtype,$net) = getnet* ($name,$aliases,$proto) = getproto* ($name,$aliases,$port,$proto) = getserv* (If the entry doesn't exist you get a null list.) In scalar context, you get the name, unless the function was a lookup by name, in which case you get the other thing, whatever it is. (If the entry doesn't exist you get the undefined value.) For example:
$uid = getpwnam($name); $name = getpwuid($num); $name = getpwent(); $gid = getgrnam($name); $name = getgrgid($num; $name = getgrent(); #etc.
In getpw*() the fields
The
For the gethost*() functions, if the
($a,$b,$c,$d) = unpack('C4',$addr[0]);
If you get tired of remembering which element of the return list contains
which return value, by-name interfaces are also provided in modules:
use File::stat; use User::pwent; $is_his = (stat($filename)->uid == pwent($whoever)->uid);
Even though it looks like they're the same method calls (uid), they aren't,
because a |
|