GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
File::HomeDir::Tiny(3) User Contributed Perl Documentation File::HomeDir::Tiny(3)

File::HomeDir::Tiny - Find your home directory

0.01

  use File::HomeDir::Tiny;
  $home = home;

This module is useful for the 90% of the time that you only need 10% of File::HomeDir's functionality. It depends on no other modules and consists of just fourteen lines of code.

"home" is exported by default. If you do not want to import it, use parentheses:

  use File::HomeDir::Tiny ();
  $home = File::HomeDir::Tiny::home;

But why would you want to type all that?

If you need more functionality than just the current user's home folder, then try File::HomeDir.

If your code is only going to run on Unix, you do not need to bother with any module. Just use the alien spaceship operator:

  ($home) = <~> ;

If your code is only going to run on 5.16 and later, again, you can use the alien spaceship:

  { use v5.16 }
  ($home) = <~> ;  # Didn't I just mention this?

If your code may need to run on Windows on perl 5.14 or earlier, where the alien spaceship does not work, then use this module:

  use File'HomeDir'Tiny;  # ' so it looks *old*
  $home = home;

Notice also that I put parentheses around $home in the spaceship examples. This is because the alien spaceship is an iterator. In scalar context it will alternate between returning the home directory and returning the undefined value. (It is alien, after all.) You can ovoid this by evaluating it in list context; either of these will work:

  ($home) = <~>;
  $hoem = (<~>)[0];

So, if you want to avoid this pitfall, or if you just prefer "home" to "a bunch of punctuation marks", use this module:

  use File::HomeDir::Tiny; # :: so it looks *new*!
  $home = home;

None except perl. I believe this module will work all the back to Perl 5.004, but have not been able to verify. The earliest I tested with was 5.8.7.

I have no idea whether this works on VMS.

Copyright (C) 2017 Father Chrysostomos <sprout [at] cpan [dot] org>

This program is free software; you may redistribute it, modify it, or both under the same terms as perl.

The Windows logic for perl 5.14 and earlier was based on this File::Glob commit by Douglas Christopher Wilson: <https://perl5.git.perl.org/perl.git/commitdiff/528bd3ce854>

File::HomeDir
2017-12-01 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.