The module can be obtained from User.

<HEAD> <TITLE>User - API for locating user information regardless of OS</TITLE> <LINK REV="made" HREF="mailto:cwilson@ece.gatech.edu"> </HEAD> <BODY>


NAME

User - API for locating user information regardless of OS


SYNOPSIS

  use User;
  my $cfg = Config::IniFiles->new
        (
          -file    => sprintf("%s/%s", User->Home, ".ncfg"),
          -default => 'Default'
        );


DESCRIPTION

This module is allows applications to retrieve per-user characteristics. At present, it contains only one method, Home(), which is used to return a location that can be expected to be a users ``Home'' directory on either Windows or Unix.

While one way of writing this would be to check for operating system and then check the expected location for an operation system of that type, I chose to do the following:

 sub Home {
  return $ENV{HOME}        if $ENV{HOME};
  return $ENV{USERPROFILE} if $ENV{USERPROFILE};
  return  "";
 }

In other words, if $HOME is defined in the user's environment, then that is used. Otherwise $USERPROFILE is used. Otherwise ``'' is returned.

A contribution for Macintosh (or any other number of OS/arch combinations) is greatly solicited.

EXPORT

None by default.


AUTHOR

T.M. Brannon, tbone@cpan.org


ACKNOWLEDGEMENTS

I would like to offer profuse thanks to my fellow perl monk at www.perlmonks.org, the_slycer, who told me where HOME could be found on Windows machines.

perl(1).

</BODY> </HTML>

In reply to User.pm: a Perl module for OS-independent per-user configuration by princepawn
in thread Windows convention for per-user configuration files for a Perl application by princepawn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.