Advertisement
Guest User

OOP Perl

a guest
Oct 23rd, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.85 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use v5.14;
  4. use strict;
  5. use warnings;
  6. use Data::Dumper;
  7.  
  8. my $wbuf=3;
  9. my $wtr;
  10. print "start $wbuf\n";
  11.  
  12. $wtr = sub {
  13.     my $done_cb = shift;
  14.     my $mbuf=$wbuf;
  15.     print "done_cb2 ".Dumper($done_cb);
  16.     print "wtr3 ".Dumper($wtr);
  17.     $wbuf--;
  18.     print "cb $wbuf $mbuf\n";
  19.     if ( $wbuf ) {
  20.         print "cb wbuf\n";
  21.         $wtr->($done_cb);
  22.     } else {
  23.         print "cb undef\n";
  24.         print "wtr4 ".Dumper($wtr);
  25.         undef $wtr;
  26.         print "wtr5 ".Dumper($wtr);
  27.         $done_cb->();
  28.         print "wtr7 ".Dumper($wtr);
  29.         print "after exit\n";
  30.     }
  31.     print "return wtr\n";
  32.     print "cb $wbuf $mbuf\n";
  33. };
  34.  
  35. print "wtr1 ".Dumper($wtr);
  36.  
  37. $wtr->(
  38.     sub {
  39.         my $done_cb = shift;
  40.         print "done_cb6 ".Dumper($done_cb);
  41.         print "exit $wbuf\n";
  42.     }
  43. );
  44.  
  45. print "stop\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement