title: How do I get the current user in Perl in a portable way?
body: <p>How does one get the current user in a portable way?</p>
  
  <p>This seems like an FAQ but <a href="http://perldoc.perl.org/perlport.html" rel="noreferrer">perlport</a> doesn't speak about it, maybe because some odd systems don't have the concept of "user" to being with? However, let's stick to *nix and Windows.</p>
  
  <p><code>getpwuid($&gt;)</code> is not implemented on Windows.</p>
  
  <p><code>$ENV{USER} || $ENV{USERNAME}</code> seems finicky.</p>
  
  <p><a href="http://search.cpan.org" rel="noreferrer">http://search.cpan.org</a> didn't turn up much.</p>