#!/usr/bin/env perl
########################################################################
# Leave directories out of the search with ignore=: the default skips
# /lib and /usr/lib, here $HOME/lib is skipped as well.  See POD.
########################################################################

use v5.40;

use FindBin::Bin    qw( $Bin_p );

# import arguments are evaluated at compile time: $ENV{ HOME } is
# available, a variable assigned at run time is not.

use FindBin::libs   qw( export=lib_default nofail );

use FindBin::libs
(
    "ignore=/,/usr,$ENV{ HOME }"
  , qw( export=lib_nohome nofail )
);

use FindBin::libs   qw( noignore export=lib_all nofail );

say "lib dirs above '$Bin_p':";

for
(
    [ 'default, ignore=/,/usr'  => \@lib_default    ]
  , [ 'ignore=/,/usr,$HOME'     => \@lib_nohome     ]
  , [ 'noignore'                => \@lib_all        ]
)
{
    my ( $name, $dirz ) = $_->@*;

    say '';
    say "$name:";
    say '    ' . ( join( "\n    ", $dirz->@* ) || '(none)' );
}

__END__

=head1 NAME

ignore_dirs - leave directories out of the search with ignore=

=head1 SYNOPSIS

    ignore_dirs

=head1 DESCRIPTION

    use FindBin::libs qw( export=lib_default nofail );

    use FindBin::libs
    (
        "ignore=/,/usr,$ENV{ HOME }"
      , qw( export=lib_nohome nofail )
    );

    use FindBin::libs qw( noignore export=lib_all nofail );

Each C<ignore> entry is a directory whose C<lib> (or other C<base>)
is not searched.  The default, C</,/usr>, skips F</lib> and
F</usr/lib>, which hold the system's libraries rather than perl
modules.  The list replaces the default, so keep C</,/usr> in it when
adding to it.

Adding C<$ENV{ HOME }> skips F<~/lib>: a program in F<~/src/app/bin>
then gets F<~/src/app/lib> without whatever else is kept in F<~/lib>.
The entries must be absolute paths, compared as given, so a
C<$HOME> that is reached through a symlink needs its physical path
for the default C<abspath> walk.

C<noignore> searches every parent, F</lib> and F</usr/lib> included.

The argument list is evaluated at compile time: C<$ENV{ HOME }> can
be used, a variable assigned when the program runs cannot.

=head1 SEE ALSO

L<FindBin::libs>, F<example/list_etc_dirs>
