Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Problem with this approach is that you don't know when errors are raised which module raised them; it might have been a dependency of the ones which you loaded. Here's one I wrote recently;

    use Test::More qw(no_plan);

    use FindBin qw($Bin);
    use File::Find;

    my @modules;
    my %uses;

    finddepth(sub {
            m{^\w.*\.pm$} && do {
                    my $module = $File::Find::name;
                    $module =~ s{.*/lib.}{};
                    $module =~ s{[/\\]}{::}g;
                    $module =~ s{.pm$}{};
                    push @modules, $module;
                    open MODULE, "<", $_ or die "Failed to open ($_): $!";
                    while(<MODULE>) {
                            if (m{^use (\S+)}) {
                            if (m{^(?:extends|with) (["'])?(\S+)\1}) {
                    close MODULE;
    }, "$Bin/../lib");

    my %done;
    while (@modules) {
            my (@winners) = grep {!$uses{$_} or !keys %{$uses{$_}}} @modules;
            if (!@winners) {
                    @winners = shift @modules;
            for my $module (sort @winners) {
                    my @fail;
                    local($SIG{__WARN__}) = sub {
                            push @fail, join " ", @_;
                            warn "# oh look a warning: @_";
                    is (@fail, 0, "no warnings issued");
                    delete $uses{$module};
                    delete $_->{$module} for values %uses;
            @modules = grep { !$done{$_} } @modules;