File::Which::Cached - faster subsequent which lookups
use File::Which::Cached 'which'; my $perl_bin = which('perl'); use File::Which::Cached; my $perl_bin = File::Which::Cached::which('perl');
This is a wrapper around File::Which that caches results to a package symbol. If you have a sub or method that makes multiple calls to which, and maybe the same executable lookup, you may want to do this.
File::Which does not cache results in the package. That means that if you call which twice for the same executable, it performs twice.
This module will save the result, so that if your code is called to lookup an executable a thousand times, it takes just as long as one time.
This is desirable in iterations of many calls, etc. In 2 thousand calls, we save one second.
Not exported by default.
Argument is name of executable, returs abs path to file. Takes one argument at a time. If you provide no argument, croaks.
Leo Charre leocharre at cpan dot org
Copyright (c) 2009 Leo Charre. All rights reserved.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License".
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the "GNU General Public License" for more details.