Skip to content

Instantly share code, notes, and snippets.

@kentfredric
Created June 4, 2009 04:36
Show Gist options
  • Save kentfredric/123437 to your computer and use it in GitHub Desktop.
Save kentfredric/123437 to your computer and use it in GitHub Desktop.
package lib::relative;
# $Id:$
use strict;
use warnings;
use parent 'lib';
sub to {
my $self = shift;
my $path = shift;
my $from = shift;
my @caller = caller;
$from ||= $caller[1];
require File::Spec;
require File::Basename;
return File::Spec->rel2abs( $path,
File::Spec->rel2abs( File::Basename::dirname($from) ) );
}
sub import {
my $self = shift;
my $path = shift;
my @caller = caller;
my $expand = $self->to( $path, $caller[1] );
unshift @_, $expand;
unshift @_, $self;
goto \&lib::import;
}
1;
__END__
Sick of doing this in your code ?
use FindBin;
use lib "$FindBin::Bin/../path/to/lib/dir";
?
Try this:
use lib::relative "../path/to/lib/dir" ;
Itch->scratch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment