Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- print "i'm before begin!\n";
- BEGIN {
- print "begin begun executed...\n";
- }
- print "lines!\n";
- die 'a';
- END {
- my $is_this_a_var='aa';
- END {
- print "END sub executed $is_this_a_var!\n";
- }
- print "END executed $is_this_a_var!\n";
- $is_this_a_var= '100';
- }
- print "last line of script\n";
- #!/usr/bin/perl
- # begincheck
- print "10. Ordinary code runs at runtime.\n";
- END { print "16. So this is the end of the tale.\n" }
- INIT { print " 7. INIT blocks run FIFO just before runtime.\n" }
- UNITCHECK {
- print " 4. And therefore before any CHECK blocks.\n"
- }
- CHECK { print " 6. So this is the sixth line.\n" }
- print "11. It runs in order, of course.\n";
- BEGIN { print " 1. BEGIN blocks run FIFO during compilation.\n" }
- END { print "15. Read perlmod for the rest of the story.\n" }
- CHECK { print " 5. CHECK blocks run LIFO after all compilation.\n" }
- INIT { print " 8. Run this again, using Perl's -c switch.\n" }
- print "12. This is anti-obfuscated code.\n";
- END { print "14. END blocks run LIFO at quitting time.\n" }
- BEGIN { print " 2. So this line comes out second.\n" }
- UNITCHECK {
- print " 3. UNITCHECK blocks run LIFO after each file is compiled.\n"
- }
- INIT { print " 9. You'll see the difference right away.\n" }
- print "13. It merely _looks_ like it should be confusing.\n";
- __END__
- use strict;
- use Data::Dumper;
- sub MODIFY_CODE_ATTRIBUTES {
- my ($class,$code,@attrs) = @_;
- print Dumper(@attrs);
- @attrs = (@attrs[0]);
- my $allowed = 'MyAttribute';
- my @bad = grep { $_ ne $allowed } @attrs;
- return @bad;
- }
- sub foo : MyAttribute : aaa("fuck") {
- print "foo\n";
- }
- &foo;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement