bdimych has asked for the wisdom of the Perl Monks concerning the following question:

is there something shorter than
BEGIN {unshift @INC, $1 if $0 =~ m|(.*)/|}

thanks

Replies are listed 'Best First'.
Re: how to add script directory to @INC
by ikegami (Patriarch) on Jan 11, 2009 at 18:02 UTC

    Shorter:

    use lib $0 =~ m|(.*)/|;

    But how about something that actually works instead. What you have there doesn't handle symlinks or non-unix systems.

    use Cwd qw( realpath ); use File::Basename qw( dirname ); use lib dirname(realpath($0));
Re: how to add script directory to @INC
by ysth (Canon) on Jan 11, 2009 at 22:49 UTC