Advertisement
happy-barney

CLEANUP counterpart

Jul 20th, 2020
646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.38 KB | None | 0 0
  1.  
  2. sub foo {
  3.     my ($type, @params) = @_;
  4.  
  5.     my %valid_types = (
  6.         foo => 'FOO',
  7.         bar => 'BAR',
  8.         baz => 'BAZ',
  9.     );
  10.  
  11.     goto $valid_types{$type} if exists $valid_types{$type};
  12.     die;
  13.  
  14.     {
  15.         COUNTERPART_TO_CLEANUP { initialize };
  16.         FOO: {
  17.             return;
  18.         }
  19.  
  20.         {
  21.             COUNTERPART_TO_CLEANUP { initialize bar and baz only };
  22.             BAR: { ...; return; }
  23.             BAZ: { ...; return; }
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement