]> git.vpit.fr Git - perl/modules/indirect.git/commitdiff
Freshen the synopsis
authorVincent Pit <vince@profvince.com>
Sun, 3 May 2009 14:23:54 +0000 (16:23 +0200)
committerVincent Pit <vince@profvince.com>
Sun, 3 May 2009 14:23:54 +0000 (16:23 +0200)
lib/indirect.pm

index 6354a1361f30c36af3a672f88a8579d03b9928e0..3794554e967a0e3e6ae08afeda4173267ebb2c21 100644 (file)
@@ -22,15 +22,27 @@ BEGIN {
 
 =head1 SYNOPSIS
 
 
 =head1 SYNOPSIS
 
+    # In a script
     no indirect;
     my $x = new Apple 1, 2, 3; # warns
     {
      use indirect;
      my $y = new Pear; # ok
     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
 
     }
     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<no indirect>), 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<sub> isn't defined, C<sub $x> is actually interpreted as C<< $x->sub >>).
 =head1 DESCRIPTION
 
 When enabled (or disabled as some may prefer to say, since you actually turn it on by calling C<no indirect>), 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<sub> isn't defined, C<sub $x> is actually interpreted as C<< $x->sub >>).