Scroll to navigation

FindBin::Bin(3pm) User Contributed Perl Documentation FindBin::Bin(3pm)

NAME

FindBin::Bin - Find the executin directory, exported via BIN()

SYNOSIS

    # if $0 is '-e' or '-' or 'interactive' then use the
    # working directory via File::Spec::Functions::curdir.
    # otherwise use vol+directory of $0.
    #
    # the path is extracted once at startup to avoid
    # issues with assignment to $0.
    # there you have it: $Bin is the path.
    use FindBin::Bin qw( $Bin );
    # sub call, sans $:
    # Bin is defines w/ no args and returns a constant string, 
    # it can be used as a sub or constant in your code. 
    
    use FindBin::Bin qw(  Bin );
    my $path = Bin;
    # Or, of course, both:
    use FindBin::Bin qw( $Bin Bin );
    say $Bin;
    /scratch/lembark/sandbox/Modules/Perl5/FindBin-libs
    say Bin;
    /scratch/lembark/sandbox/Modules/Perl5/FindBin-libs
2025-11-09 perl v5.40.1