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