File-Path-Expand-1.02/0000775000076700001200000000000010430650412015305 5ustar richardcadmin00000000000000File-Path-Expand-1.02/Build.PL0000664000076700001200000000043510430650412016603 0ustar richardcadmin00000000000000#!perl -w use strict; use Module::Build; Module::Build ->new( module_name => "File::Path::Expand", license => 'perl', requires => { 'Test::More' => 0, }, create_makefile_pl => 'traditional', ) ->create_build_script; File-Path-Expand-1.02/Changes0000664000076700001200000000036210430650412016601 0ustar richardcadmin000000000000001.02 Thursday 11th May, 2006 Apply the patch from http://rt.cpan.org/Ticket/Display.html?id=13081 1.01 Sunday 11th May, 2003 Bugfix to the test suite - had miscounted the number of skipped tests 1.0 Sunday 11th May, 2003 Initial release File-Path-Expand-1.02/lib/0000775000076700001200000000000010430650412016053 5ustar richardcadmin00000000000000File-Path-Expand-1.02/lib/File/0000775000076700001200000000000010430650412016732 5ustar richardcadmin00000000000000File-Path-Expand-1.02/lib/File/Path/0000775000076700001200000000000010430650412017626 5ustar richardcadmin00000000000000File-Path-Expand-1.02/lib/File/Path/Expand.pm0000664000076700001200000000230210430650412021400 0ustar richardcadmin00000000000000use strict; package File::Path::Expand; use User::pwent; use Carp qw(croak); use Exporter; use base 'Exporter'; use vars qw( $VERSION @EXPORT @EXPORT_OK ); $VERSION = '1.02'; @EXPORT = qw( expand_filename ); @EXPORT_OK = qw( expand_filename home_of ); sub expand_filename { my $path = shift; $path =~ s{^~(?=/|$)}{ $ENV{HOME} ? "$ENV{HOME}" : home_of( $> ) }e or $path =~ s{^~(.+?)(?=/|$)}{ home_of( $1 ) }e; return $path; } sub home_of { my $user = shift; my $ent = getpw($user) or croak "no such user '$user'"; return $ent->dir; } 1; __END__ =head1 NAME File::Path::Expand - expand filenames =head1 SYNOPSIS use File::Path::Expand; print expand_filename("~richardc/foo"); # prints "/home/richardc/foo" =head1 DESCRIPTION File::Path::Expand expands user directories in filenames. For the simple case it's no more complex than s{^~/}{$HOME/}, but for other cases it consults C and does the right thing. =head1 AUTHOR Richard Clamp =head1 COPYRIGHT Copyright (c) 2003, Richard Clamp. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. =cut File-Path-Expand-1.02/Makefile.PL0000664000076700001200000000060310430650412017256 0ustar richardcadmin00000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.03 use ExtUtils::MakeMaker; WriteMakefile ( 'PL_FILES' => {}, 'INSTALLDIRS' => 'site', 'NAME' => 'File::Path::Expand', 'VERSION_FROM' => 'lib/File/Path/Expand.pm', 'PREREQ_PM' => { 'Test::More' => 0 } ) ; File-Path-Expand-1.02/MANIFEST0000664000076700001200000000013410430650412016434 0ustar richardcadmin00000000000000Build.PL Makefile.PL Changes MANIFEST META.yml lib/File/Path/Expand.pm t/File-Path-Expand.t File-Path-Expand-1.02/META.yml0000664000076700001200000000043510430650412016560 0ustar richardcadmin00000000000000--- name: File-Path-Expand version: 1.02 author: - Richard Clamp abstract: expand filenames license: perl requires: Test::More: 0 provides: File::Path::Expand: file: lib/File/Path/Expand.pm version: 1.02 generated_by: Module::Build version 0.261 File-Path-Expand-1.02/t/0000775000076700001200000000000010430650412015550 5ustar richardcadmin00000000000000File-Path-Expand-1.02/t/File-Path-Expand.t0000664000076700001200000000161110430650412020722 0ustar richardcadmin00000000000000#!perl -w use strict; use Test::More tests => 8; use Sys::Hostname; BEGIN { use_ok('File::Path::Expand') }; $ENV{HOME} = '/some/path'; is( expand_filename('~/foo'), "/some/path/foo", 'uses $HOME' ); is( expand_filename('~'), $ENV{HOME}, '...and similarly for ~' ); SKIP: { skip "only guaranteed on penfold", 5 unless hostname eq 'penfold.unixbeard.net'; SKIP: { skip "have to be richardc too", 2 unless $> eq 1000; $ENV{HOME} = ''; is( expand_filename("~/foo"), "/home/richardc/foo", 'without $HOME ~/' ); is( expand_filename("~"), "/home/richardc", '...and similarly for ~' ); } is( expand_filename('~root/foo'), "/root/foo", 'root' ); is( expand_filename('~root'), "/root", '...and similarly for ~root' ); eval { expand_filename('~frooby/') }; like( $@, qr{^no such user 'frooby'}, "failure" ); }