Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. use strict;
  2.  
  3. print "i'm before begin!\n";
  4.  
  5.  
  6. BEGIN {
  7. print "begin begun executed...\n";
  8. }
  9.  
  10. print "lines!\n";
  11. die 'a';
  12.  
  13. END {
  14. my $is_this_a_var='aa';
  15. END {
  16.  
  17. print "END sub executed $is_this_a_var!\n";
  18. }
  19.  
  20.  
  21. print "END executed $is_this_a_var!\n";
  22. $is_this_a_var= '100';
  23. }
  24.  
  25.  
  26. print "last line of script\n";
  27.  
  28. #!/usr/bin/perl
  29.  
  30. # begincheck
  31.  
  32. print "10. Ordinary code runs at runtime.\n";
  33.  
  34. END { print "16. So this is the end of the tale.\n" }
  35. INIT { print " 7. INIT blocks run FIFO just before runtime.\n" }
  36. UNITCHECK {
  37. print " 4. And therefore before any CHECK blocks.\n"
  38. }
  39. CHECK { print " 6. So this is the sixth line.\n" }
  40.  
  41. print "11. It runs in order, of course.\n";
  42.  
  43. BEGIN { print " 1. BEGIN blocks run FIFO during compilation.\n" }
  44. END { print "15. Read perlmod for the rest of the story.\n" }
  45. CHECK { print " 5. CHECK blocks run LIFO after all compilation.\n" }
  46. INIT { print " 8. Run this again, using Perl's -c switch.\n" }
  47.  
  48. print "12. This is anti-obfuscated code.\n";
  49.  
  50. END { print "14. END blocks run LIFO at quitting time.\n" }
  51. BEGIN { print " 2. So this line comes out second.\n" }
  52. UNITCHECK {
  53. print " 3. UNITCHECK blocks run LIFO after each file is compiled.\n"
  54. }
  55. INIT { print " 9. You'll see the difference right away.\n" }
  56.  
  57. print "13. It merely _looks_ like it should be confusing.\n";
  58.  
  59. __END__
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. use strict;
  68. use Data::Dumper;
  69.  
  70. sub MODIFY_CODE_ATTRIBUTES {
  71. my ($class,$code,@attrs) = @_;
  72.  
  73. print Dumper(@attrs);
  74. @attrs = (@attrs[0]);
  75. my $allowed = 'MyAttribute';
  76. my @bad = grep { $_ ne $allowed } @attrs;
  77.  
  78. return @bad;
  79. }
  80.  
  81. sub foo : MyAttribute : aaa("fuck") {
  82. print "foo\n";
  83. }
  84.  
  85. &foo;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement