1User(3) User Contributed Perl Documentation User(3)
2
3
4
6 User - API for locating user information regardless of OS
7
9 use User;
10
11 my $cfg = Config::IniFiles->new
12 (
13 -file => sprintf("%s/%s", User->Home, ".ncfg"),
14 -default => 'Default'
15 );
16
17 print "Your login is ", User->Login, "\n";
18
20 This module is allows applications to retrieve per-user
21 characteristics.
22
24 Home
25 Returns a location that can be expected to be a users "Home"
26 directory on either Windows or Unix.
27
28 While one way of writing this would be to check for operating
29 system and then check the expected location for an operation system
30 of that type, I chose to do the following:
31
32 sub Home {
33
34 return $ENV{HOME} if $ENV{HOME};
35 return $ENV{USERPROFILE} if $ENV{USERPROFILE};
36 return "";
37
38 }
39
40 In other words, if $HOME is defined in the user's environment, then
41 that is used. Otherwise $USERPROFILE is used. Otherwise "" is
42 returned.
43
44 A contribution for Macintosh (or any other number of OS/arch
45 combinations) is greatly solicited.
46
47 Login
48 Returns login id of user on either Unix or NT by checking
49 "getlogin", "getpwuid", and various environment variables.
50
52 File::HomeDir seems to be a very well-done update of the same concept
53 as this module.
54
56 Copyright: Copyright (c) 2002-2010 Terrence Brannon. All rights
57 reserved. This program is free software; you can redistribute it
58 and/or modify it under the same terms as Perl itself.
59
60 License: GPL, Artistic, available in the Debian Linux Distribution at
61 /usr/share/common-licenses/{GPL,Artistic}
62
64 T.M. Brannon, tbone@cpan.org
65
66 I am grateful for additions by Rob Napier and Malcom Nooning.
67
69 I would like to offer profuse thanks to my fellow perl monk at
70 www.perlmonks.org, the_slycer, who told me where HOME could be found on
71 Windows machines.
72
73 I would also like to thank Bob Armstrong for providing me with the text
74 of the copyright notice and for including this in the Debian Linux
75 distribution.
76
77 perl(1).
78
79
80
81perl v5.32.0 2020-07-28 User(3)