diff options
| author | Abigail <abigail@abigail.be> | 2021-04-09 19:26:59 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-04-09 19:26:59 +0200 |
| commit | 7c398511d67d05283111bf310ee7156e1df8aa1e (patch) | |
| tree | 6bfb382b7b7c6e0f9597cf388ae1350cd994a434 | |
| parent | fafed8e98f280132fc442d11508e810700ab4a08 (diff) | |
| download | perlweeklychallenge-club-7c398511d67d05283111bf310ee7156e1df8aa1e.tar.gz perlweeklychallenge-club-7c398511d67d05283111bf310ee7156e1df8aa1e.tar.bz2 perlweeklychallenge-club-7c398511d67d05283111bf310ee7156e1df8aa1e.zip | |
Don't print BEGIN twice
| -rw-r--r-- | challenge-107/abigail/perl/ch-2.pl | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/challenge-107/abigail/perl/ch-2.pl b/challenge-107/abigail/perl/ch-2.pl index bc74d27e4c..e87f8aef71 100644 --- a/challenge-107/abigail/perl/ch-2.pl +++ b/challenge-107/abigail/perl/ch-2.pl @@ -41,6 +41,10 @@ my $symbol_table = do {no strict 'refs'; \%{$module . "::"}}; # which symbols have a code ref entry in the type glob. # (The symbol table maps symbols to type globs). # +# Note that this only gives use the global methods, no lexical +# subroutines are found that way. Which is ok, as lexical +# subroutines are bound to their lexical scope - not the package. +# foreach my $symbol (keys %$symbol_table) { say $symbol if *{$$symbol_table {$symbol}} {CODE}; } @@ -56,7 +60,7 @@ foreach my $symbol (keys %$symbol_table) { # We will *NOT* do the same for END, INIT, CHECK, nor UNITCHECK. # One piece of madness is enough. # -say "BEGIN" if $$symbol_table {BEGIN}; +say "BEGIN" if $$symbol_table {BEGIN} && !*{$$symbol_table {BEGIN}} {CODE}; # # Note that if the module contains an AUTOLOAD method, one could argue |
