home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / languages / perl / nutshell / ch3 / etcpass < prev    next >
Encoding:
Text File  |  1992-10-18  |  569 b   |  21 lines

  1. #!/usr/bin/perl
  2.  
  3. # a report on the /etc/passwd file
  4. format top =
  5.             Passwd File
  6. Name                Login    Office   Uid   Gid Home
  7. ---------------------------------------------------------------
  8. .
  9. format STDOUT =
  10. @<<<<<<<<<<<<<<<<<< @||||||| @<<<<<<@>>>> @>>>> @<<<<<<<<<<<<<<
  11. $name,              $login,  $office,$uid,$gid, $home
  12. .
  13.  
  14. open(PASSWD, "/etc/passwd") || die "Can't open passwd: $!\n";
  15. while (<PASSWD>) {
  16.     chop;
  17.     ($login,$passwd,$uid,$gid,$gcos,$home,$shell) = split(/:/);
  18.     ($name,$office,$phone) = split(/,/,$gcos); # (BSD specific!)
  19.     write;
  20. }
  21.