Path::ExpandTilde - Expand tilde (~) to homedir in file paths
my $homedir = expand_tilde('~');
my $bashrc = expand_tilde('~/.bashrc');
my $pg_home = expand_tilde('~postgres');
This module uses bsd_glob from File::Glob to portably expand a leading tilde (~) in a file path into the current or specified user's home directory. No other glob metacharacters are expanded.
my $new_path = expand_tilde($path);
Exported by default. If the path starts with ~, expands that to the current user's home directory. If the path starts with ~username, expands that to the specified user's home directory. If the user doesn't exist, no expansion is done. The returned path is canonicalized as by "canonpath" in File::Spec either way.
The algorithm should be portable to most operating systems supported by Perl, though the home directory may not be found by bsd_glob on some.
Report any issues on the public bugtracker.
Dan Book <email@example.com>
This software is Copyright (c) 2018 by Dan Book.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
File::Path::Expand, File::HomeDir, File::HomeDir::Tiny
To install Path::ExpandTilde, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.