diff --git a/lib/File/Which.pm b/lib/File/Which.pm index f09a84e..c8c1b38 100644 --- a/lib/File/Which.pm +++ b/lib/File/Which.pm @@ -178,9 +178,6 @@ sub _default_path { } else { @path = File::Spec->path; } - if ( $self->{implicit_current_dir} ) { - unshift @path, File::Spec->curdir; - } \@path; } @@ -257,6 +254,12 @@ sub which { ? @{ $self->{fixed_paths} } : @{ $self->_default_path }; + # implicit_current_dir is added after getting the paths + # so that changes in the $CWD are applied + if ( $self->{implicit_current_dir} ) { + unshift @path, File::Spec->curdir; + } + my @PATHEXT = @{ $self->{PATHEXT} }; foreach my $base ( map { File::Spec->catfile($_, $exec) } @path ) { for my $ext ( @PATHEXT ) {