X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=lib%2Findirect.pm;h=3794554e967a0e3e6ae08afeda4173267ebb2c21;hp=6354a1361f30c36af3a672f88a8579d03b9928e0;hb=d818cd7cde8dc811471d3b02134e043077bd55e4;hpb=36e1f9a23b073751223769b71f1e84643913e592 diff --git a/lib/indirect.pm b/lib/indirect.pm index 6354a13..3794554 100644 --- a/lib/indirect.pm +++ b/lib/indirect.pm @@ -22,15 +22,27 @@ BEGIN { =head1 SYNOPSIS + # In a script no indirect; my $x = new Apple 1, 2, 3; # warns { use indirect; my $y = new Pear; # ok + { + no indirect hook => sub { die "You really wanted $_[0]\->$_[1]" }; + my $z = new Pineapple 'fresh'; # croaks 'You really wanted Pineapple->new' + } } no indirect ':fatal'; if (defied $foo) { ... } # croaks, note the typo + # From the command-line + perl -M-indirect -e 'my $x = new Banana;' # warns + + # Or each time perl is ran + export PERL5OPT="-M-indirect" + perl -e 'my $y = new Coconut;' # warns + =head1 DESCRIPTION When enabled (or disabled as some may prefer to say, since you actually turn it on by calling C), this pragma warns about indirect object syntax constructs that may have slipped into your code. This syntax is now considered harmful, since its parsing has many quirks and its use is error prone (when C isn't defined, C is actually interpreted as C<< $x->sub >>).