Acme-AtIncPolice

 view release on metacpan or  search on metacpan

lib/Acme/AtIncPolice.pm  view on Meta::CPAN

        # use scalar/array/hash ?
        return unless grep lc($class) eq lc($_) , @{$op->{use}};
        # create warning message
        my $watch_msg = '';
        my $msg = $self->_output_message($class, $value, \%args);
        if(defined $self->{options}->{pkg}){
            $watch_msg = sprintf("%s:: %s", @{$self->{options}}{qw/pkg var/});
        } else {
            $msg =~ s/^ => // if $msg;
        }
        if ($msg) {
            croak $watch_msg . $msg . "\n";
        }
    };

    watch @INC, (
        debug => sub {
            my ($self, $things) = @_;
            for my $thing (@$things) {
                my $ref = ref($thing);
                if ($ref) {
                    return "Acme::AtIncPolice does not allow contamination of \@INC";
                }
            }
        },
        r => 0,
    );
};


1;
__END__

=encoding utf-8

=head1 NAME

Acme::AtIncPolice - The police that opponents to @INC contamination

=head1 SYNOPSIS

    use Acme::AtIncPolice;
    # be killed by Acme::AtIncPolice
    push @INC, sub {
        my ($coderef, $filename) = @_;
        my $modfile = "lib/$filename";
        if (-f $modfile) {
            open my $fh, '<', $modfile;
            return $fh;
        }
    };
    # be no-op ed by Acme::AtIncPolice
    push @INC, "lib";

=head1 DESCRIPTION

If you use Acme::AtIncPolice, your program be died when detects any reference value from @INC.

=head2 MOTIVE

@INC hooks is one of useful feature in the Perl. It's used inside of some clever modules.

But, @INC hooks provoke confuse in several cases. 

A feature that resolve library path dynamically is needed on your project that is simple web application? Really? 

The answer is "NO".

Let's go on. Acme::AtIncPolice gives clean programming experience to you. Under Acme::AtIncPolice, @INC hooks is prohibited.

If you found a "smelly" program, Let use Acme::AtIncPolice on it.

=head1 LICENSE

Copyright (C) ytnobody.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 AUTHOR

ytnobody E<lt>ytnobody@gmail.comE<gt>

=cut



( run in 1.264 second using v1.01-cache-2.11-cpan-0d23b851a93 )