home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7060 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.5 KB  |  38 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!news.centerline.com!noc.near.net!meiko.com!mike
  3. From: mike@meiko.com (Mike Stok)
  4. Subject: Re: Need tidbit of code to look up user's full name
  5. Message-ID: <1992Nov19.133453.29766@meiko.com>
  6. Sender: news@meiko.com
  7. Organization: Meiko Scientific Corp.
  8. References: <1992Nov19.025121.4550@cis.ohio-state.edu>
  9. Distribution: usa
  10. Date: Thu, 19 Nov 1992 13:34:53 GMT
  11. Lines: 25
  12.  
  13. In article <1992Nov19.025121.4550@cis.ohio-state.edu> fontana@iguana.cis.ohio-state.edu (Mark Fontana) writes:
  14. >I'm just beginning to learn perl, and I would like to have a program
  15. >determine the first name of the user invoking it.  Presently, it
  16. >gets the user's login name through environment variable USER.  I
  17. >would like the program to determine the user's full name (by checking
  18. >the gecos(?) field).  I'd appreciate it if someone could give an
  19. >example of how to do this.
  20.  
  21. Assuming that the user's first name is the first thing in the gcos
  22. field in the password file then this should work...
  23.  
  24. $name = (split (' ', (getpwuid ($<))[6], 2))[0];
  25.  
  26. If you're just beginning to learn perl I would *strongly* recommend
  27. getting hold of a copy of the "Camel book" ("programming perl" by
  28. Larry Wall and Randal Schwartz, published by O'Reilly & Associates,
  29. and if my copy hadn't been borrowed I could give you the ISBN :-).
  30.  
  31. Mike
  32.  
  33. --
  34. The "usual disclaimers" apply.    |
  35. Mike Stok                         |
  36. mike@meiko.com                    |
  37. Meiko tel: (617) 890 7676         |
  38.