描述
此函數將枚舉設置(或重置)到組條目集的開頭。這個函數應該在第一次調用 getgrent 之前調用。
用法
以下是此函數的簡單語法 -
setgrent
返回值
此函數不返回任何值。
示例
以下是顯示其基本用法的示例代碼 -
#!/usr/bin/perl -w
while( ($name,$passwd,$gid,$members) = getgrent() ) {
print "Name = $name\n";
print "Password = $passwd\n";
print "GID = $gid\n";
print "Members = $members\n";
}
setgrent(); # Set the beginnging of the group database;
print "Again reading /etc/passwd file\n";
while( ($name,$passwd,$gid,$members) = getgrent() ) {
print "Name = $name\n";
print "Password = $passwd\n";
print "GID = $gid\n";
print "Members = $members\n";
}
endpwent; #claose the database;
執行上述代碼時,會產生以下結果 -
Name = root Password = x GID = 0 Members = root Name = bin Password = x GID = 1 Members = root bin daemon Name = daemon Password = x GID = 2 Members = root bin daemon Name = sys Password = x GID = 3 Members = root bin adm Name = adm Password = x GID = 4 Members = root adm daemon . . . Name = kvm Password = x GID = 36 Members = qemu Name = qemu Password = x GID = 107 Members = Name = com Password = x GID = 501 Members = Name = webgrp Password = x GID = 502 Members = com Name = railo Password = x GID = 495 Members =
相關用法
- Perl setpriority用法及代碼示例
- Perl setpwent用法及代碼示例
- Perl sethostent用法及代碼示例
- Perl setsockopt用法及代碼示例
- Perl setprotoent用法及代碼示例
- Perl setnetent用法及代碼示例
- Perl setservent用法及代碼示例
- Perl semget用法及代碼示例
- Perl send用法及代碼示例
- Perl seekdir用法及代碼示例
- Perl semctl用法及代碼示例
- Perl semop用法及代碼示例
- Perl select用法及代碼示例
- Perl sin()用法及代碼示例
- Perl split用法及代碼示例
- Perl shmctl用法及代碼示例
- Perl splice用法及代碼示例
注:本文由純淨天空篩選整理自 Perl setgrent Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。