From a427078823d98890edb7ea4e32dac807ab3de243 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Quelin?= Date: Sun, 15 Feb 2009 18:57:53 +0100 Subject: [PATCH] don't be fooled by tabbed lines in prereq output see XML::Parser::Style::EasyTree with the following output: === BEGIN OUTPUT === [...] ==> Auto-install the 1 mandatory module(s) from CPAN? [y] *** Since we're running under CPANPLUS, I'll just let it take care of the dependency's installation later. *** Module::AutoInstall configuration finished. [...] === END OUTPUT === we need to be smart and not count this tabbed line --- lib/App/CPAN2Pkg/Module.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/App/CPAN2Pkg/Module.pm b/lib/App/CPAN2Pkg/Module.pm index 8713601..4d479f0 100644 --- a/lib/App/CPAN2Pkg/Module.pm +++ b/lib/App/CPAN2Pkg/Module.pm @@ -23,6 +23,7 @@ use Class::XSAccessor _srpm => '_srpm', _wheel => '_wheel', }; +use List::MoreUtils qw{ firstidx }; use POE; use POE::Filter::Line; use POE::Wheel::Run; @@ -313,13 +314,11 @@ sub _find_prereqs { $self->_wheel(undef); # extract prereqs - my @lines = - grep { s/^\s+// } - split /\n/, $self->_output; - shift @lines; # remove the title line - my @prereqs = - map { (split /\s+/, $_)[0] } - @lines; + my @lines = split /\n/, $self->_output; + my @tabbed = grep { s/^\s+// } @lines; + my $idx = firstidx { /^Module\s+Req Ver.*Satisfied/ } @tabbed; + my @wanted = @tabbed[ $idx+1 .. $#tabbed ]; + my @prereqs = map { (split /\s+/, $_)[0] } @wanted; # store prereqs $self->_prereqs( \@prereqs ); -- 2.11.4.GIT