>>>>> On Tue, 27 Jan 2009 18:24:26 -0500, David Golden <[email protected]> said:
> When I looked at this for a question on stackoverflow, I concluded that the
thing to do was
> check $mod->uptodate rather than rely on the return value of install.
> my $mod = CPAN::Shell->expand("Module", "Module::Name::Here");
> if ( ! $mod->uptodate ) {
> $mod->install;
> die "Problems installing" unless $mod->uptodate;
> }
Yes, and that's even in the manpage:
Note that install() gives no meaningful return value. See uptodate().
> As I recall, a lot of things return to shortcut control flow and
> those aren't necessarily consistent in returning true/false.
> Depending on how they are invoked, I think some of those values
> just fall through to the end of install.
> I'd prefer to see things either return true/false, but it may be
> that things should return an object that can provide context. E.g.
> "tests passed, but dependency was missing" -- is that success for
> "test Foo::Bar" or failure? If running CPAN::Shell->test(*) then
> it's success, but when CPAN::Shell->install calls test() then it's
> a failure. (That might be a contrived example, so please don't nit
> pick me over it.) Many of the functions in CPAN::Distribution do
> return CPAN::Distrostatus objects, but I don't think that works
> for routines from Shell that might be called against module names,
> not distribution names.
Given that you can pass an array of arbitrary length to install() but
uptodate() is for one object, I figured that I cannot produce a
meaningful return value. Jos once mentioned that this is more or less
the main reason why he created CPANPLUS.
--
andreas