Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/perl/lib/Attribute/Handlers/demo/demo_chain.pl

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#! /usr/local/bin/perl -w

use Attribute::Handlers;

sub Prefix : ATTR {
  my ($glob, $sub) = @_[1,2];
  no warnings 'redefine';
  *$glob = sub {
                 print "This happens first\n";
                 $sub->(@_);
               };
}

sub Postfix : ATTR {
  my ($glob, $sub) = @_[1,2];
  no warnings 'redefine';
  *$glob = sub {
                 $sub->(@_);
                 print "This happens last\n";
               };
}

sub test : Postfix Prefix {
  print "Hello World\n";
}

test();

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].