home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7058 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  1.4 KB

  1. Path: sparky!uunet!noc.near.net!bigboote.WPI.EDU!bigboote.wpi.edu!john
  2. From: john@sekrit.WPI.EDU (John Stoffel)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Need tidbit of code to look up user's full name
  5. Date: 19 Nov 92 08:39:07
  6. Organization: Worcester Polytechnic Institute
  7. Lines: 25
  8. Distribution: usa
  9. Message-ID: <JOHN.92Nov19083907@sekrit.WPI.EDU>
  10. References: <1992Nov19.025121.4550@cis.ohio-state.edu>
  11. NNTP-Posting-Host: sekrit.wpi.edu
  12. In-reply-to: fontana@iguana.cis.ohio-state.edu's message of 19 Nov 92 02:51:21 GMT
  13.  
  14. >>>>> On 19 Nov 92 02:51:21 GMT, fontana@iguana.cis.ohio-state.edu (Mark Fontana) said:
  15. Mark> Article-I.D.: cis.1992Nov19.025121.4550
  16.  
  17.  
  18. Mark> Hi,
  19.  
  20. Mark> I'm just beginning to learn perl, and I would like to have a program
  21. Mark> determine the first name of the user invoking it.  Presently, it
  22. Mark> gets the user's login name through environment variable USER.  I
  23. Mark> would like the program to determine the user's full name (by checking
  24. Mark> the gecos(?) field).  I'd appreciate it if someone could give an
  25. Mark> example of how to do this.
  26.  
  27. #!/usr/local/bin/perl
  28.  
  29. @user = getpwuid($<);
  30. @name = split(/ /,$user[6],2);
  31. print "$name[0]\n";
  32.  
  33.  
  34. --
  35. Youth of today!  Join me in a mass rally for traditional mental attitudes!
  36. -------------------------------------------------------------------------------
  37. john@wpi.wpi.edu | Work Station Specialist | Worcester Polytechnic Institute
  38. John Stoffel     | 508-831-5512 (work)     | Worcester, MA  01609
  39.