kentfredric (owner)

Revisions

gist: 220449 Download_button fork
public
Public Clone URL: git://gist.github.com/220449.git
Embed All Files: show embed
Perl #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
use strict;
use warnings;
 
use Data::Dumper;
 
use namespace::clean;
 
BEGIN {
  my $symtab;
  {
    no strict 'refs';
    $symtab = \%{'main::'};
  }
  last if ( exists $symtab->{'foo'} );
  my $debugging = sub() { 0 };
  if ( exists $ENV{'TEST_DEBUGGING'} ) {
    $debugging = sub(){ 1 } if (( $ENV{'TEST_DEBUGGING'} + 0 ) > 0 );
  }
  {
    no strict 'refs';
    *{'main::foo'} = $debugging;
  }
}
 
print '.' . foo . '/';
 
if (foo) {
  print 1;
}
else {
  print 0;
}
 
sub bar {
  my %symtab;
  {
    no strict 'refs';
    %symtab = %{'main::'};
  }
  if ( exists $symtab{'foo'} ) {
    print 'exists';
  }
  print $symtab{'foo'}->();
  print Dumper(\%symtab );
}
 
bar();