FindBin::Bin(3pm)

πŸ“¦ version 4.0.4, in ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

FindBin::Bin β€” it finds the executin directory πŸ’– and exports it via BIN().

(Yes bestie, "executin" β€” that's exactly how the original spells it, and we do not correct the icons in this house πŸ’…)


✨ SYNOSIS ✨

okay so here's the entire vibe, and I am copying it character for character because code is sacred 🫢:

    # 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

πŸ¦‹ the breakdown, bestie πŸ¦‹

  • if $0 is '-e' or '-' or 'interactive', it uses the working directory via File::Spec::Functions::curdir. Otherwise it uses vol+directory of $0. ✨
  • the path gets extracted once at startup β€” literally the whole point β€” so you don't get issues with assignment to $0. πŸ™ˆ
  • and there you have it: $Bin is the path. πŸ’…

πŸŽ€ the sub call, sans $ πŸŽ€

Bin is defines w/ no args and returns a constant string, so you can use it as a sub or as a constant in your code. πŸ‘‘

  • pull in $Bin with use FindBin::Bin qw( $Bin ); πŸ’–
  • pull in Bin with use FindBin::Bin qw( Bin ); and then my $path = Bin; 🌸
  • or, of course, both: use FindBin::Bin qw( $Bin Bin ); β€” main character energy fr fr πŸ’€

and when you run it, both of these:

    say $Bin;
    /scratch/lembark/sandbox/Modules/Perl5/FindBin-libs

    say Bin;
    /scratch/lembark/sandbox/Modules/Perl5/FindBin-libs

give you back /scratch/lembark/sandbox/Modules/Perl5/FindBin-libs. Same energy, two doors, one path. πŸ“


heads up bestie: $Bin is the path β€” that's it, that's the whole module. No cap. 🧚

and that's the page!! 🌈 brought to you by perl v5.40.1, dated 2025-11-09 β€” from the User Contributed Perl Documentation, with love, and also from FindBin::Bin(3pm) itself. periodt. πŸ’œβœ¨

πŸ“¦ where this page comes from